Class: MongoidAutoInc::Incrementor

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

Defined Under Namespace

Classes: Sequence

Instance Method Summary collapse

Constructor Details

#initialize(options = nil) ⇒ Incrementor

Returns a new instance of Incrementor.



52
53
54
55
56
# File 'lib/mongoid_auto_inc/incrementor.rb', line 52

def initialize(options=nil)
  options ||= {}
  @collection = options[:collection] || "sequences"
  @seed = options[:seed].to_i
end

Instance Method Details

#[](sequence) ⇒ Object



58
59
60
# File 'lib/mongoid_auto_inc/incrementor.rb', line 58

def [](sequence)
  Sequence.new(sequence, @collection, @seed)
end

#[]=(sequence, number) ⇒ Object



62
63
64
# File 'lib/mongoid_auto_inc/incrementor.rb', line 62

def []=(sequence, number)
  Sequence.new(sequence, @collection, @seed).set(number)
end