Module: Trax::Model::Restorable

Extended by:
Mixin
Defined in:
lib/trax/model/restorable.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mixin

after_included, extended, mixed, mixed_in

Class Method Details

.apply_mixin(target, options) ⇒ Object



54
55
56
57
58
# File 'lib/trax/model/restorable.rb', line 54

def self.apply_mixin(target, options)
  target.restorable_config.merge!(options)

  target.setup_restorable!
end

Instance Method Details

#destroyObject



46
47
48
# File 'lib/trax/model/restorable.rb', line 46

def destroy
  self.update_attributes(self.class.restorable_config.field => true, self.class.restorable_config.timestamp_field => ::DateTime.now)
end

#restoreObject



50
51
52
# File 'lib/trax/model/restorable.rb', line 50

def restore
  self.update_attributes(self.class.restorable_config.field => false, self.class.restorable_config.timestamp_field => ::DateTime.now)
end