Sha256: 0d724cf275a65239e875597625e11e5a150ad1732d91b66b80726ca979f2eb7a
Contents?: true
Size: 894 Bytes
Versions: 14
Compression:
Stored size: 894 Bytes
Contents
module CassandraObject module Identity class NaturalKeyFactory < AbstractKeyFactory class NaturalKey include Key attr_reader :value def initialize(value) @value = value end def to_s value end def to_param value end def ==(other) other.is_a?(NaturalKey) && other.value == value end def eql?(other) other == self end end attr_reader :attributes, :separator def initialize(options) @attributes = [*options[:attributes]] @separator = options[:separator] || "-" end def next_key(object) NaturalKey.new(attributes.map { |a| object.attributes[a.to_s] }.join(separator)) end def parse(paramized_key) NaturalKey.new(paramized_key) end end end end
Version data entries
14 entries across 14 versions & 1 rubygems