1
0
Fork 0
mirror of https://github.com/paper-trail-gem/paper_trail.git synced 2022-11-09 11:33:19 -05:00

Extract private method: reify_associations

This commit is contained in:
Jared Beck 2016-03-13 19:23:15 -04:00
parent b381dc41b4
commit b14e7719aa
2 changed files with 16 additions and 10 deletions

View file

@ -39,6 +39,12 @@ Style/DotPosition:
Style/DoubleNegation:
Enabled: false
# The decision of when to use a guard clause to improve readability is subtle,
# and it's not clear that it can be linted. Certainly, the default
# `MinBodyLength` of 1 can actually hurt readability.
Style/GuardClause:
MinBodyLength: 3
# The Ruby Style Guide says:
#
# > Use \ instead of + or << to concatenate two string literals at line end.

View file

@ -53,22 +53,22 @@ module PaperTrail
end
reify_attributes(model, version, attrs)
model.send "#{model.class.version_association_name}=", version
unless options[:has_one] == false
reify_has_ones version.transaction_id, model, options
end
unless options[:has_many] == false
reify_has_manys version.transaction_id, model, options
end
reify_associations(model, options, version)
model
end
private
def reify_associations(model, options, version)
if options[:has_one]
reify_has_ones version.transaction_id, model, options
end
if options[:has_many]
reify_has_manys version.transaction_id, model, options
end
end
# Set all the attributes in this version on the model.
def reify_attributes(model, version, attrs)
enums = model.class.respond_to?(:defined_enums) ? model.class.defined_enums : {}