Sha256: 627358d97ce72854d48cc6d2c4710d6d58dcf0ee9ba335262094fe5f8585ee1e

Contents?: true

Size: 340 Bytes

Versions: 3

Compression:

Stored size: 340 Bytes

Contents

module ActiveMocker
module Mock
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

3 entries across 3 versions & 1 rubygems

Version Path
active_mocker-1.5.2 lib/active_mocker/mock/next_id.rb
active_mocker-1.5.1 lib/active_mocker/mock/next_id.rb
active_mocker-1.5 lib/active_mocker/mock/next_id.rb