Module: Mongoid::PublishingLogic::ModuleMethods
- Defined in:
- lib/mongoid/publishing_logic.rb
Instance Method Summary collapse
- #activate ⇒ Object
- #activated(&block) ⇒ Object
- #active? ⇒ Boolean
- #deactivate ⇒ Object
- #deactivated(&block) ⇒ Object
- #with_status(status, &block) ⇒ Object
Instance Method Details
#activate ⇒ Object
74 75 76 |
# File 'lib/mongoid/publishing_logic.rb', line 74 def activate self.active = true end |
#activated(&block) ⇒ Object
86 87 88 |
# File 'lib/mongoid/publishing_logic.rb', line 86 def activated(&block) with_status(true, &block) end |
#active? ⇒ Boolean
70 71 72 |
# File 'lib/mongoid/publishing_logic.rb', line 70 def active? self.active end |
#deactivate ⇒ Object
78 79 80 |
# File 'lib/mongoid/publishing_logic.rb', line 78 def deactivate self.active = false end |
#deactivated(&block) ⇒ Object
82 83 84 |
# File 'lib/mongoid/publishing_logic.rb', line 82 def deactivated(&block) with_status(false, &block) end |
#with_status(status, &block) ⇒ Object
90 91 92 93 94 95 96 97 98 |
# File 'lib/mongoid/publishing_logic.rb', line 90 def with_status(status, &block) status_was = active? begin self.active = status yield ensure self.active = status_was end end |