Sha256: e5879f298db66aa1f655623c215c966ce67fa857360fc83450c0d6dfc65cf6aa
Contents?: true
Size: 724 Bytes
Versions: 2
Compression:
Stored size: 724 Bytes
Contents
module DirtyAttributes def self.included(base) base.extend ClassMethods base.send :include, InstanceMethods base.send :include, MethodMap end module ClassMethods def attrs(*names) @attrs = names.collect(&:to_s) end def attributes @attrs end end module InstanceMethods attr_reader :attributes def initialize @attributes = DirtyHashy.new({}, true, self.class.attributes).tap do |hashy| dirty_map! hashy clean_up! end end def attributes=(other) attributes.replace other rescue IndexError => e e.message.match /"(.*)"/ raise NoMethodError, "undefined method `#{$1}=' for #{self.inspect}" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dirty_hashy-0.1.3 | lib/dirty_attributes.rb |
dirty_hashy-0.1.2 | lib/dirty_attributes.rb |