Sha256: ba5dee3df7ec394b664944798bd9538dfca466122641221dd3498ad3d70c5909
Contents?: true
Size: 663 Bytes
Versions: 1
Compression:
Stored size: 663 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 attrs = self.class.attributes.inject({}){|h, a| h.merge({a => nil})} @attributes = DirtyHashy.new(attrs).tap do |hashy| dirty_map! hashy, attrs.keys clean_up! end end def attributes=(other) attributes.clear.merge! other end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dirty_hashy-0.1.1 | lib/dirty_attributes.rb |