Skip to content

Commit 7cf94a3

Browse files
committed
refactor reify method
1 parent edcb27b commit 7cf94a3

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

lib/paper_trail/reifier.rb

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,7 @@ def reify(version, options)
7575

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

78-
unless options[:has_one] == false
79-
reify_has_ones version.transaction_id, model, options
80-
end
81-
82-
unless options[:belongs_to] == false
83-
reify_belongs_tos version.transaction_id, model, options
84-
end
85-
86-
unless options[:has_many] == false
87-
reify_has_manys version.transaction_id, model, options
88-
end
89-
90-
model
78+
reify_assoications version, model, options
9179
end
9280

9381
private
@@ -131,6 +119,16 @@ def prepare_array_for_has_many(array, options, versions)
131119
nil
132120
end
133121

122+
def reify_assoications version, model, options
123+
reify_has_ones version.transaction_id, model, options if options[:has_one]
124+
125+
reify_belongs_tos version.transaction_id, model, options if options[:belongs_to]
126+
127+
reify_has_manys version.transaction_id, model, options if options[:has_many]
128+
129+
model
130+
end
131+
134132
# Restore the `model`'s has_one associations as they were when this
135133
# version was superseded by the next (because that's what the user was
136134
# looking at when they made the change).

0 commit comments

Comments
 (0)