Class: ActiveMocker::Mock::NextId Private

Inherits:
Object
  • Object
show all
Defined in:
lib/active_mocker/mock/next_id.rb

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.

Instance Method Summary collapse

Constructor Details

#initialize(records) ⇒ NextId

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.

Returns a new instance of NextId.



6
7
8
# File 'lib/active_mocker/mock/next_id.rb', line 6

def initialize(records)
  @records = records
end

Instance Method Details

#nextObject

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.

Raises:



10
11
12
13
14
# File 'lib/active_mocker/mock/next_id.rb', line 10

def next
  return 1 if max_record.nil?
  return max_record.id.succ if max_record.id.is_a?(Numeric)
  raise IdNotNumber
end