Module: AttributesHistory::HasAttributesHistory::ClassMethods

Defined in:
lib/attributes_history/has_attributes_history.rb

Instance Method Summary collapse

Instance Method Details

#has_attributes_history(options) ⇒ Object

The options should include the keys :attributes and :version_class



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/attributes_history/has_attributes_history.rb', line 19

def has_attributes_history(options)
  history_model = options[:with_model]
  history_attributes = options[:for].map(&:to_s)
  history_association = history_model.name.underscore.pluralize.to_sym

  has_many history_association

  store_history_options(history_model, history_attributes, history_association)
  setup_history_callback(history_attributes, history_model)
  define_attribute_on_date_methods(history_attributes)
end

#history_association(attribute) ⇒ Object



35
36
37
# File 'lib/attributes_history/has_attributes_history.rb', line 35

def history_association(attribute)
  self.history_associations[attribute]
end

#history_model(attribute) ⇒ Object



31
32
33
# File 'lib/attributes_history/has_attributes_history.rb', line 31

def history_model(attribute)
  self.history_models[attribute]
end