Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean-up mutation tracking setup #113

Merged
merged 1 commit into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/aws-record/record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ module Record
# # Attribute definitions go here...
# end
def self.included(sub_class)
@track_mutations = true
sub_class.send(:extend, RecordClassMethods)
sub_class.send(:include, Attributes)
sub_class.send(:include, ItemOperations)
Expand Down Expand Up @@ -201,7 +200,11 @@ def enable_mutation_tracking
# @return [Boolean] true if mutation tracking is enabled at the model
# level, false otherwise.
def mutation_tracking_enabled?
@track_mutations == false ? false : true
if defined?(@track_mutations)
@track_mutations
else
@track_mutations = true
end
end

def model_valid?
Expand Down
4 changes: 4 additions & 0 deletions spec/aws-record/record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ module Aws
end
}

it 'is on by default' do
expect(model.mutation_tracking_enabled?).to be_truthy
end

it 'can turn off mutation tracking globally for a model' do
model.disable_mutation_tracking
expect(model.mutation_tracking_enabled?).to be_falsy
Expand Down