Module: Trax::Model::Mixins::Restorable
Defined Under Namespace
Modules: ClassMethods
Class Method Summary
collapse
Instance Method Summary
collapse
after_included, extended, mixed, mixed_in
Class Method Details
.apply_mixin(target, options) ⇒ Object
55
56
57
58
59
|
# File 'lib/trax/model/mixins/restorable.rb', line 55
def self.apply_mixin(target, options)
target.restorable_config.merge!(options)
target.setup_restorable!
end
|
Instance Method Details
#destroy ⇒ Object
47
48
49
|
# File 'lib/trax/model/mixins/restorable.rb', line 47
def destroy
self.update_attributes(self.class.restorable_config.field => true, self.class.restorable_config.timestamp_field => ::DateTime.now)
end
|
#restore ⇒ Object
51
52
53
|
# File 'lib/trax/model/mixins/restorable.rb', line 51
def restore
self.update_attributes(self.class.restorable_config.field => false, self.class.restorable_config.timestamp_field => ::DateTime.now)
end
|