Module: ActiveExtend::ActiveDisablable
- Defined in:
- lib/active_extend/active_disablable.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #destroy ⇒ Object
- #destroy_fully ⇒ Object
- #disable ⇒ Object
- #disabled? ⇒ Boolean
- #enable ⇒ Object
- #enabled? ⇒ Boolean
- #recovery ⇒ Object
Class Method Details
.included(base) ⇒ Object
7 8 9 10 |
# File 'lib/active_extend/active_disablable.rb', line 7 def self.included(base) base.extend(ClassMethods) base.send(:default_scope) { base.where(:enabled => true) } end |
Instance Method Details
#destroy ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/active_extend/active_disablable.rb', line 41 def destroy if (@destroy_fully || self.disabled?) super else disable self.save end end |
#destroy_fully ⇒ Object
55 56 57 58 |
# File 'lib/active_extend/active_disablable.rb', line 55 def destroy_fully @destroy_fully = true self.destroy end |
#disable ⇒ Object
25 26 27 |
# File 'lib/active_extend/active_disablable.rb', line 25 def disable self.enabled = false end |
#disabled? ⇒ Boolean
37 38 39 |
# File 'lib/active_extend/active_disablable.rb', line 37 def disabled? !self.enabled end |
#enable ⇒ Object
29 30 31 |
# File 'lib/active_extend/active_disablable.rb', line 29 def enable self.enabled = true end |
#enabled? ⇒ Boolean
33 34 35 |
# File 'lib/active_extend/active_disablable.rb', line 33 def enabled? self.enabled end |
#recovery ⇒ Object
50 51 52 53 |
# File 'lib/active_extend/active_disablable.rb', line 50 def recovery enable self.save end |