Module: RailLine::ResultDo
- Defined in:
- lib/rail_line/result_do.rb,
lib/rail_line/result_do/thread_context.rb
Overview
Utilized for enabling RailLine functionality
Use include RailLine::ResultDo or include RailLine::ResultDo to include handle_result functionality.
Defined Under Namespace
Modules: ClassMethods, ThreadContext
Class Method Summary collapse
-
.[](*method_names) ⇒ Module
Enables the use of the automatic handling of results.
- .included(base) ⇒ Object
Instance Method Summary collapse
-
#handle_result { ... } ⇒ RailLine::Failure, RailLine::Success
The result of the block.
Class Method Details
.[](*method_names) ⇒ Module
Enables the use of the automatic handling of results.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rail_line/result_do.rb', line 38 def self.[](*method_names) Module.new do define_singleton_method(:included) do |base| base.extend(RailLine::ResultDo::ClassMethods) wrapped_methods = Module.new do method_names.each do |method_name| define_method(method_name) do |*args, **kwargs| base.handle_result { super(*args, **kwargs) } end end end base.prepend(wrapped_methods) base.singleton_class.prepend(wrapped_methods) end end end |
.included(base) ⇒ Object
21 22 23 |
# File 'lib/rail_line/result_do.rb', line 21 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#handle_result { ... } ⇒ RailLine::Failure, RailLine::Success
Returns The result of the block.
122 123 124 |
# File 'lib/rail_line/result_do.rb', line 122 def handle_result(&block) self.class.handle_result(&block) end |