Module: Mongoid::Autoinc::ClassMethods

Defined in:
lib/autoinc.rb

Instance Method Summary collapse

Instance Method Details

#incrementing_fieldsObject



17
18
19
20
21
22
23
# File 'lib/autoinc.rb', line 17

def incrementing_fields
  if superclass.respond_to?(:incrementing_fields)
    @incrementing_fields ||= superclass.incrementing_fields.dup
  else
    @incrementing_fields ||= {}
  end
end

#increments(field, options = {}) ⇒ Object



25
26
27
28
# File 'lib/autoinc.rb', line 25

def increments(field, options={})
  incrementing_fields[field] = options.reverse_merge!(:auto => true)
  attr_protected field
end