Module: Flexite::WithHistory

Extended by:
ActiveSupport::Concern
Included in:
Config, Entry
Defined in:
app/models/concerns/flexite/with_history.rb

Instance Method Summary collapse

Instance Method Details

#restore(history) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/models/concerns/flexite/with_history.rb', line 15

def restore(history)
  history.history_attributes.each do |attr|
    self[attr.name] = attr.value
  end

  self.class.skip_callback(:save, :after, :save_history)

  begin
    save!
  ensure
    self.class.set_callback(:save, :after, :save_history)
  end
end