Module: HashPipe::SingletonMethods
- Defined in:
- lib/hashpipe.rb
Instance Method Summary collapse
-
#archived_attribute_definitions ⇒ Object
Returns the attachment definitions defined by each call to has_attached_file.
- #hattr(*args) ⇒ Object
Instance Method Details
#archived_attribute_definitions ⇒ Object
Returns the attachment definitions defined by each call to has_attached_file.
40 41 42 |
# File 'lib/hashpipe.rb', line 40 def archived_attribute_definitions read_inheritable_attribute(:archived_attribute_definitions) end |
#hattr(*args) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/hashpipe.rb', line 12 def hattr(*args) attribute = args.first = args. .reverse_merge! :marshalled => false if archived_attribute_definitions.nil? write_inheritable_attribute(:archived_attribute_definitions, {}) after_save :save_archived_attributes before_destroy :destroy_archived_attributes end archived_attribute_definitions[attribute] = self.__send__(:include, InstanceMethods) define_method attribute do archive_stash_for(attribute).value end define_method "#{attribute}=" do |value| archive_stash_for(attribute).value = value end end |