Module: ActiveMetadata::Persistence::History::InstanceMethods

Defined in:
lib/active_metadata/persistence/history.rb

Instance Method Summary collapse

Instance Method Details

#history_for(field, order = "created_at DESC") ⇒ Object



19
20
21
22
23
# File 'lib/active_metadata/persistence/history.rb', line 19

def history_for field, order="created_at DESC"
  Rails.cache.fetch(history_cache_key(field), :expires_in => ActiveMetadata::CONFIG['cache_expires_in'].try(:minutes)) do
    fetch_histories_for field, order
  end
end

#save_historyObject



9
10
11
12
13
14
15
16
17
# File 'lib/active_metadata/persistence/history.rb', line 9

def save_history
  return if ActiveMetadata.skip_history?
  self.changes.each do |key, value|
    next if ActiveMetadata::CONFIG['history_skip_fields'].include?(key) || !change_is_valid_for_history?(value)
    ActiveMetadata::History.create! :value => value[1],:model_class => , :model_id => ,:label => key.to_s, :created_by => current_user_id
    invalidate_history_cache_for key.to_s
    self.send(:send_notification, key, value[0], value[1], :history_message, current_user_id) unless skip_history_notification?
  end
end