Module: ArchivedAttributes::InstanceMethods
- Defined in:
- lib/archived_attributes.rb
Instance Method Summary collapse
- #archive_stash_for(model) ⇒ Object
- #destroy_archived_attributes ⇒ Object
- #each_archived_stash ⇒ Object
- #generate_uuid ⇒ Object
- #save_archived_attributes ⇒ Object
Instance Method Details
#archive_stash_for(model) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/archived_attributes.rb', line 50 def archive_stash_for(model) @_archived_attribute_stashes ||= {} @_archived_attribute_stashes[model] ||= ArchivedAttribute.new( model, self, self.class.archived_attribute_definitions[model] ) end |
#destroy_archived_attributes ⇒ Object
69 70 71 72 73 |
# File 'lib/archived_attributes.rb', line 69 def destroy_archived_attributes each_archived_stash do |name, stash| stash.__send__(:destroy) end end |
#each_archived_stash ⇒ Object
57 58 59 60 61 |
# File 'lib/archived_attributes.rb', line 57 def each_archived_stash self.class.archived_attribute_definitions.each do |name, definition| yield(name, archive_stash_for(name)) end end |
#generate_uuid ⇒ Object
75 76 77 |
# File 'lib/archived_attributes.rb', line 75 def generate_uuid self.uuid = UUID.new.generate if self.new_record? end |
#save_archived_attributes ⇒ Object
63 64 65 66 67 |
# File 'lib/archived_attributes.rb', line 63 def save_archived_attributes each_archived_stash do |name, stash| stash.__send__(:save) end end |