Sha256: ec447c586af274dab10f67caf7ff07f6cc57a98652993b34ab16d0a419645012

Contents?: true

Size: 355 Bytes

Versions: 14

Compression:

Stored size: 355 Bytes

Contents

module ActiveMocker
module Mock
# @api private
class NextId

  def initialize(records)
    @records = records
  end

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

  private

  def max_record
    @max_record ||= @records.max { |a, b| a.id <=> b.id }
  end

end
end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
active_mocker-1.7.3 lib/active_mocker/mock/next_id.rb
active_mocker-1.7.2 lib/active_mocker/mock/next_id.rb
active_mocker-1.7.1 lib/active_mocker/mock/next_id.rb
active_mocker-1.7.1rc lib/active_mocker/mock/next_id.rb
active_mocker-1.7 lib/active_mocker/mock/next_id.rb
active_mocker-1.7rc2 lib/active_mocker/mock/next_id.rb
active_mocker-1.7.beta3 lib/active_mocker/mock/next_id.rb
active_mocker-1.7.beta2 lib/active_mocker/mock/next_id.rb
active_mocker-1.6.4 lib/active_mocker/mock/next_id.rb
active_mocker-1.7.beta1 lib/active_mocker/mock/next_id.rb
active_mocker-1.6.3 lib/active_mocker/mock/next_id.rb
active_mocker-1.6.2 lib/active_mocker/mock/next_id.rb
active_mocker-1.6.1 lib/active_mocker/mock/next_id.rb
active_mocker-1.6 lib/active_mocker/mock/next_id.rb