Sha256: 0547f4ac0eef7498ba81db133d6dd092be1fa930fa627462f8ecd8ebbd628cd3
Contents?: true
Size: 1.06 KB
Versions: 2
Compression:
Stored size: 1.06 KB
Contents
module ActiveMetadata::Persistence::ActiveRecord::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) History.create! :value => value[1],: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 Rails.cache.fetch(history_cache_key(field), :expires_in => ActiveMetadata::CONFIG['cache_expires_in'].minutes) do fetch_histories_for field end end private def invalidate_history_cache_for field Rails.cache.delete history_cache_key(field) end def fetch_histories_for field History.all(:conditions => {:document_id => metadata_id,:label => field}, :order => "created_at DESC") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_metadata-0.2.2 | lib/active_metadata/persistence/active_record/history.rb |
active_metadata-0.2.1 | lib/active_metadata/persistence/active_record/history.rb |