Class: Beholder
- Inherits:
-
Object
- Object
- Beholder
- Defined in:
- lib/beholders/beholder.rb
Class Method Summary collapse
- .disable! ⇒ Object
- .disable_all! ⇒ Object
- .disabled=(value) ⇒ Object
- .disabled? ⇒ Boolean
- .enable! ⇒ Object
- .enable_all! ⇒ Object
- .inherited(subclass) ⇒ Object
- .self_and_descendants ⇒ Object
- .trigger(action, model) ⇒ Object
Class Method Details
.disable! ⇒ Object
10 11 12 |
# File 'lib/beholders/beholder.rb', line 10 def self.disable! @disabled = true end |
.disable_all! ⇒ Object
34 35 36 |
# File 'lib/beholders/beholder.rb', line 34 def self.disable_all! self_and_descendants.each(&:disable!) end |
.disabled=(value) ⇒ Object
22 23 24 |
# File 'lib/beholders/beholder.rb', line 22 def self.disabled=(value) @disabled = value end |
.disabled? ⇒ Boolean
18 19 20 |
# File 'lib/beholders/beholder.rb', line 18 def self.disabled? @disabled end |
.enable! ⇒ Object
14 15 16 |
# File 'lib/beholders/beholder.rb', line 14 def self.enable! @disabled = false end |
.enable_all! ⇒ Object
30 31 32 |
# File 'lib/beholders/beholder.rb', line 30 def self.enable_all! self_and_descendants.each(&:enable!) end |
.inherited(subclass) ⇒ Object
5 6 7 8 |
# File 'lib/beholders/beholder.rb', line 5 def self.inherited(subclass) super subclass.disabled = subclass.superclass.disabled? end |
.self_and_descendants ⇒ Object
26 27 28 |
# File 'lib/beholders/beholder.rb', line 26 def self.self_and_descendants [self] + descendants end |
.trigger(action, model) ⇒ Object
38 39 40 41 |
# File 'lib/beholders/beholder.rb', line 38 def self.trigger(action, model) return if disabled? new.public_send(action, model) if method_defined? action end |