Sha256: b00b34807a3af63b881e09d5a0c19c6457e44ccc956023ca1bc84c781daa2573
Contents?: true
Size: 671 Bytes
Versions: 2
Compression:
Stored size: 671 Bytes
Contents
module Structural 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_sym))) end def eql? other other.is_a?(Structural::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(ivar, &b) instance_variable_get(ivar) || instance_variable_set(ivar, b.call(data)) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
structural-0.2.0 | lib/structural/model.rb |
structural-0.1.0 | lib/structural/model.rb |