Module: ActiveDisablable
- Included in:
- City, CompanyBusiness, Customer, TaskType, User
- 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
6 7 8 9 |
# File 'lib/active_extend/active_disablable.rb', line 6 def self.included(base) base.extend(ClassMethods) base.send(:default_scope) { base.where(:enabled => true) } end |
Instance Method Details
#destroy ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/active_extend/active_disablable.rb', line 40 def destroy if (@destroy_fully || self.disabled?) super else disable self.save end end |
#destroy_fully ⇒ Object
54 55 56 57 |
# File 'lib/active_extend/active_disablable.rb', line 54 def destroy_fully @destroy_fully = true self.destroy end |
#disable ⇒ Object
24 25 26 |
# File 'lib/active_extend/active_disablable.rb', line 24 def disable self.enabled = false end |
#disabled? ⇒ Boolean
36 37 38 |
# File 'lib/active_extend/active_disablable.rb', line 36 def disabled? !self.enabled end |
#enable ⇒ Object
28 29 30 |
# File 'lib/active_extend/active_disablable.rb', line 28 def enable self.enabled = true end |
#enabled? ⇒ Boolean
32 33 34 |
# File 'lib/active_extend/active_disablable.rb', line 32 def enabled? self.enabled end |
#recovery ⇒ Object
49 50 51 52 |
# File 'lib/active_extend/active_disablable.rb', line 49 def recovery enable self.save end |