Class: CanDo::Dsl::Cascade

Inherits:
Object
  • Object
show all
Defined in:
lib/can_do/dsl.rb

Instance Method Summary collapse

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

#reasonObject



68
69
70
# File 'lib/can_do/dsl.rb', line 68

def reason
  @reason
end