Sha256: 63a30e0e548b98058039707a84c3128697975383e32ffd40f2d915ce03c10d8f
Contents?: true
Size: 657 Bytes
Versions: 3
Compression:
Stored size: 657 Bytes
Contents
module Id module Model attr_reader :data def initialize(data = {}) @data = Hashifier.hashify(data) end def set(values) self.class.new(data.merge(Hashifier.hashify(values))) end def unset(*keys) self.class.new(data.except(*keys.map(&:to_s))) end def eql? other other.is_a?(Id::Model) && other.data.eql?(self.data) end alias_method :==, :eql? def hash data.hash end private def self.included(base) base.extend(Descriptor) end def memoize(f, &b) instance_variable_get("@#{f}") || instance_variable_set("@#{f}", b.call(data)) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
id-0.0.12 | lib/id/model.rb |
id-0.0.11 | lib/id/model.rb |
id-0.0.10 | lib/id/model.rb |