Module: Mongoid::Historicals::ClassMethods

Defined in:
lib/mongoid/historicals.rb

Instance Method Summary collapse

Instance Method Details

#historicals(*attrs, options = {}) ⇒ Object

This model should record historical values for the specified attributes.

Parameters:

  • attrs (Array)

    The symbol(s) for the attributes for which you want to store historicals

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :max (Integer)

    The maximum number of entries to store (default: unlimited)

  • :frequency (:monthly, :weekly, :daily)

    The frequency to use for DateTime labels (default: :daily)



91
92
93
94
95
96
97
98
# File 'lib/mongoid/historicals.rb', line 91

def historicals(*attrs)
  options = attrs.extract_options!
  options[:max] ||= nil
  options[:frequency] ||= :daily

  self.historical_options = options
  self.historical_attributes = attrs
end