Sha256: dd25c8153b191730f134d1c17fa61bdec38233e09fafd6edc449c146e2d9ca66
Contents?: true
Size: 822 Bytes
Versions: 1
Compression:
Stored size: 822 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 def as_form @form_object ||= self.class.form_object.new(self) end def errors as_form.errors end def valid? as_form.valid? end private def self.included(base) base.extend(Descriptor) end def memoize(f, &b) instance_variable_get("@#{f}") || instance_variable_set("@#{f}", b.call) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
id-0.0.9 | lib/id/model.rb |