Module: SharedBehaviour::Deprecatable

Included in:
Product, ProductCriteria
Defined in:
app/models/shared_behaviour/deprecatable.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


2
3
4
5
6
# File 'app/models/shared_behaviour/deprecatable.rb', line 2

def self.included(base)
  base.class_eval do
    scope :active, ->() { where(deprecated_at: nil) }
  end
end

Instance Method Details

#deprecate!Object


8
9
10
11
# File 'app/models/shared_behaviour/deprecatable.rb', line 8

def deprecate!
  self.deprecated_at = DateTime.now
  save!
end

#deprecated?Boolean

If we have a datestamp we are deprecated


14
15
16
# File 'app/models/shared_behaviour/deprecatable.rb', line 14

def deprecated?
  deprecated_at?
end