Module: Hyperion::DispatchDsl
- Included in:
- DispatchingHyperionResult
- Defined in:
- lib/hyperion/result_handling/dispatch_dsl.rb
Overview
This is a DSL of sorts that gives the ‘request` block a nice way to dispatch the result based on status, HTTP code, etc.
Instance Method Summary collapse
Instance Method Details
#__set_escape_continuation__(k) ⇒ Object
10 11 12 |
# File 'lib/hyperion/result_handling/dispatch_dsl.rb', line 10 def __set_escape_continuation__(k) @escape = k end |
#when(condition, &action) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/hyperion/result_handling/dispatch_dsl.rb', line 14 def when(condition, &action) pred = as_predicate(condition) is_match = Util.nil_if_error { Proc.loose_call(pred, [self]) } if is_match return_value = action.call(self) @escape.call(return_value) # non-local exit else nil end end |