Skip to content

Commit

Permalink
refactor reify method
Browse files Browse the repository at this point in the history
  • Loading branch information
theRealNG committed Mar 13, 2016
1 parent edcb27b commit 7cf94a3
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions lib/paper_trail/reifier.rb
Expand Up @@ -75,19 +75,7 @@ def reify(version, options)

model.send "#{model.class.version_association_name}=", version

unless options[:has_one] == false
reify_has_ones version.transaction_id, model, options
end

unless options[:belongs_to] == false
reify_belongs_tos version.transaction_id, model, options
end

unless options[:has_many] == false
reify_has_manys version.transaction_id, model, options
end

model
reify_assoications version, model, options
end

private
Expand Down Expand Up @@ -131,6 +119,16 @@ def prepare_array_for_has_many(array, options, versions)
nil
end

def reify_assoications version, model, options
reify_has_ones version.transaction_id, model, options if options[:has_one]

reify_belongs_tos version.transaction_id, model, options if options[:belongs_to]

reify_has_manys version.transaction_id, model, options if options[:has_many]

model
end

# Restore the `model`'s has_one associations as they were when this
# version was superseded by the next (because that's what the user was
# looking at when they made the change).
Expand Down

0 comments on commit 7cf94a3

Please sign in to comment.