Sha256: bc8e2928ed12563db1cae8e2a38bd7868f9bb20021c22ad410487c95e1e8d95c
Contents?: true
Size: 1.16 KB
Versions: 7
Compression:
Stored size: 1.16 KB
Contents
module ActiveMetadata::Persistence::History def self.included(receiver) receiver.send :include, InstanceMethods end module InstanceMethods def save_history self.changes.each do |key, value| next if ActiveMetadata::CONFIG['history_skip_fields'].include?(key) ActiveMetadata::History.create! :value => value[1],:document_class => metadata_class, :document_id => metadata_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) end end def history_for field, order="created_at DESC" Rails.cache.fetch(history_cache_key(field), :expires_in => ActiveMetadata::CONFIG['cache_expires_in'].minutes) do fetch_histories_for field, order end end private def invalidate_history_cache_for field Rails.cache.delete history_cache_key(field) end def fetch_histories_for field, order ActiveMetadata::History.all(:conditions => {:document_class => metadata_class, :document_id => metadata_id,:label => field}, :order => order) end end end
Version data entries
7 entries across 7 versions & 1 rubygems