module Flows::Result::Do::Util
Utility functions for Flows::Result::Do
.
Isolated location prevents polluting user classes with unnecessary methods.
@api private
Public Class Methods
define_wrapper(mod, method_name)
click to toggle source
`:reek:TooManyStatements` - allowed because we have no choice here.
`:reek:NestedIterators` - allowed here because here are no iterators.
Calls superclass method
# File lib/flows/result/do.rb, line 149 def define_wrapper(mod, method_name) # rubocop:disable Metrics/MethodLength mod.define_method(method_name) do |*args| super(*args) do |*fields, result| case result when Flows::Result::Ok data = result.unwrap fields.any? ? data.values_at(*fields) : data when Flows::Result::Err then return result else raise "Unexpected result: #{result.inspect}. Should be a Flows::Result" end end end end
fetch_and_prepend_module(mod)
click to toggle source
# File lib/flows/result/do.rb, line 140 def fetch_and_prepend_module(mod) module_for_do = mod.instance_variable_get(MOD_VAR_NAME) mod.prepend(module_for_do) module_for_do end