Module: SoftDestroyable::IsSoftDestroyable
- Defined in:
- lib/soft_destroyable/is_soft_destroyable.rb
Overview
Simply adds a flag to determine whether a model class is soft_destroyable.
Class Method Summary collapse
-
.extended(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#soft_destroyable? ⇒ Boolean
For all ActiveRecord::Base models that do not call the
soft_destroyable
method, thesoft_destroyable?
method will return false. -
#soft_destroyable_with_flag(*args) ⇒ Object
Overrides the
soft_destroyable
method to first define thesoft_destroyable?
class method before deferring to the originalsoft_destroyable
.
Class Method Details
.extended(base) ⇒ Object
:nodoc:
4 5 6 7 8 9 10 |
# File 'lib/soft_destroyable/is_soft_destroyable.rb', line 4 def self.extended(base) # :nodoc: base.class_eval do class << self alias_method_chain :soft_destroyable, :flag end end end |
Instance Method Details
#soft_destroyable? ⇒ Boolean
For all ActiveRecord::Base models that do not call the soft_destroyable
method, the soft_destroyable?
method will return false.
26 27 28 |
# File 'lib/soft_destroyable/is_soft_destroyable.rb', line 26 def soft_destroyable? false end |
#soft_destroyable_with_flag(*args) ⇒ Object
Overrides the soft_destroyable
method to first define the soft_destroyable?
class method before deferring to the original soft_destroyable
.
14 15 16 17 18 19 20 21 22 |
# File 'lib/soft_destroyable/is_soft_destroyable.rb', line 14 def soft_destroyable_with_flag(*args) soft_destroyable_without_flag(*args) class << self def soft_destroyable? true end end end |