Sha256: 4bc9bb9a7cac54fa8251902fc56ac432ed878e5253317340a657ce3f98c16b37

Contents?: true

Size: 425 Bytes

Versions: 2

Compression:

Stored size: 425 Bytes

Contents

module PassiveRecord
  class SecureRandomIdentifier < Struct.new(:value)
    def self.generate(klass)
      new(generate_id_value_for(klass))
    end

    def self.generate_id_value_for(*)
      SecureRandom.uuid
    end

    def ==(other_id)
      self.value == other_id ||
        (other_id.is_a?(SecureRandomIdentifier) && (other_id && self.value == other_id.value))
    end

    def inspect
      value
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
passive_record-0.4.1 lib/passive_record/core/identifier.rb
passive_record-0.4.0 lib/passive_record/core/identifier.rb