Class: Firefly::CodeFactory

Inherits:
Object
  • Object
show all
Includes:
DataMapper::Resource
Defined in:
lib/tmin/code_factory.rb

Class Method Summary collapse

Class Method Details

.next_code!Object

Returns the next auto increment value and updates the counter



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/tmin/code_factory.rb', line 11

def self.next_code!
  code = nil

  Firefly::CodeFactory.transaction do
    c = Firefly::CodeFactory.first
    code = Firefly::Base62.encode(c.count + 1)
    c.update(:count => c.count + 1)
  end

  code
end