Module: ActiveTree::Statusable
- Extended by:
- ActiveSupport::Concern
- Included in:
- Model
- Defined in:
- lib/active_tree/models/concerns/statusable.rb
Instance Method Summary collapse
- #active! ⇒ Object
- #active? ⇒ Boolean
- #inactive! ⇒ Object
- #inactive? ⇒ Boolean
- #set_default_status ⇒ Object
- #status? ⇒ Boolean
- #toggle_status! ⇒ Object
Instance Method Details
#active! ⇒ Object
43 44 45 |
# File 'lib/active_tree/models/concerns/statusable.rb', line 43 def active! self.update(status: 1) end |
#active? ⇒ Boolean
36 37 38 |
# File 'lib/active_tree/models/concerns/statusable.rb', line 36 def active? status == 1 end |
#inactive! ⇒ Object
46 47 48 |
# File 'lib/active_tree/models/concerns/statusable.rb', line 46 def inactive! self.update(status: 0) end |
#inactive? ⇒ Boolean
39 40 41 |
# File 'lib/active_tree/models/concerns/statusable.rb', line 39 def inactive? status == 0 end |
#set_default_status ⇒ Object
20 21 22 |
# File 'lib/active_tree/models/concerns/statusable.rb', line 20 def set_default_status self.status ||= 1 end |
#status? ⇒ Boolean
32 33 34 |
# File 'lib/active_tree/models/concerns/statusable.rb', line 32 def status? [:inactive, :active][ status ] end |
#toggle_status! ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/active_tree/models/concerns/statusable.rb', line 24 def toggle_status! if active? inactive! else active! end end |