Class: MongoidAutoIncrement::Incrementor

Inherits:
Object
  • Object
show all
Defined in:
lib/mongoid_auto_increment/incrementor.rb

Defined Under Namespace

Classes: Sequence

Instance Method Summary collapse

Constructor Details

#initialize(options = nil) ⇒ Incrementor

Returns a new instance of Incrementor.



57
58
# File 'lib/mongoid_auto_increment/incrementor.rb', line 57

def initialize(options=nil)
end

Instance Method Details

#inc(sequence, options) ⇒ Object



60
61
62
63
64
65
66
# File 'lib/mongoid_auto_increment/incrementor.rb', line 60

def inc(sequence, options)
  options ||= {}
  collection = options[:collection] || "sequences"
  seed = options[:seed].to_i
  step = options[:step] || 1
  Sequence.new(sequence, collection, seed, step).inc
end