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.



65
66
# File 'lib/mongoid_auto_increment/incrementor.rb', line 65

def initialize(options=nil)
end

Instance Method Details

#inc(sequence, options) ⇒ Object



68
69
70
71
72
73
# File 'lib/mongoid_auto_increment/incrementor.rb', line 68

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