Module: RecordHistory::Model::ClassMethods

Defined in:
lib/record_history/has_record_history.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) has_record_history(options = {})



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/record_history/has_record_history.rb', line 9

def has_record_history(options={})
	send :include, InstanceMethods

	attr_accessor :record_history_obj

	class_attribute :record_history_ignore
     self.record_history_ignore = ([options[:ignore]].flatten.compact || []).map{|attr| attr.to_s}

     class_attribute :record_history_only
     self.record_history_only = ([options[:only]].flatten.compact || []).map{|attr| attr.to_s}

	has_many :record_history,
              :class_name => 'RecordHistoryModel',
              :order      => "created_at DESC",
              :as         => :item

     before_save :build_record_history_obj
     after_save :save_record_history_obj
end

- (Object) is_record_history_author(options = {})



29
30
31
32
33
34
# File 'lib/record_history/has_record_history.rb', line 29

def is_record_history_author(options={})
  has_many :history,
           :class_name => 'RecordHistoryModel',
           :order      => "created_at DESC",
           :as         => :author
end