Class: CanDo::Dsl::Cascade
- Inherits:
-
Object
- Object
- CanDo::Dsl::Cascade
- Defined in:
- lib/can_do/dsl.rb
Instance Method Summary collapse
- #call(object, noun) ⇒ Object
-
#initialize(action, ability, &block) ⇒ Cascade
constructor
A new instance of Cascade.
- #reason ⇒ Object
Constructor Details
#initialize(action, ability, &block) ⇒ Cascade
Returns a new instance of Cascade.
62 63 64 65 66 |
# File 'lib/can_do/dsl.rb', line 62 def initialize(action, ability, &block) @action = action @ability = ability @transformation = block end |
Instance Method Details
#call(object, noun) ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/can_do/dsl.rb', line 72 def call(object, noun) @reason = nil object = @transformation.call(object) if @transformation noun = @ability.noun(object) if @transformation @reason = @ability.internal_reason(@action, noun, object) @reason.nil? end |
#reason ⇒ Object
68 69 70 |
# File 'lib/can_do/dsl.rb', line 68 def reason @reason end |