Class: Lotus::Model::Adapters::Memory::Collection::PrimaryKey Private

Inherits:
Object
  • Object
show all
Defined in:
lib/lotus/model/adapters/memory/collection.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A counter that simulates autoincrement primary key of a SQL table.

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initializeLotus::Model::Adapters::Memory::Collection::PrimaryKey

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize

Since:

  • 0.1.0



21
22
23
# File 'lib/lotus/model/adapters/memory/collection.rb', line 21

def initialize
  @current = 0
end

Instance Method Details

#increment! {|@current += 1| ... } ⇒ Fixnum

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Increment the current count by 1 and yields the given block

Yields:

  • (@current += 1)

Returns:

  • (Fixnum)

    the incremented counter

Since:

  • 0.1.0



31
32
33
34
# File 'lib/lotus/model/adapters/memory/collection.rb', line 31

def increment!
  yield(@current += 1)
  @current
end