Class: Wee::AnswerDecoration::Interceptor

Inherits:
Object
  • Object
show all
Defined in:
lib/wee/decoration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(action_callback, answer_callback) ⇒ Interceptor

Returns a new instance of Interceptor.



132
133
134
# File 'lib/wee/decoration.rb', line 132

def initialize(action_callback, answer_callback)
  @action_callback, @answer_callback = action_callback, answer_callback
end

Instance Attribute Details

#action_callbackObject

Returns the value of attribute action_callback.



130
131
132
# File 'lib/wee/decoration.rb', line 130

def action_callback
  @action_callback
end

#answer_callbackObject

Returns the value of attribute answer_callback.



130
131
132
# File 'lib/wee/decoration.rb', line 130

def answer_callback
  @answer_callback
end

Instance Method Details

#callObject



136
137
138
139
140
141
# File 'lib/wee/decoration.rb', line 136

def call
  @action_callback.call
rescue Answer => answer
  # return to the calling component 
  @answer_callback.call(answer)
end