Module: Dry::Monads::Do
- Defined in:
- lib/dry/monads/do.rb,
lib/dry/monads/do/all.rb
Overview
An implementation of do-notation.
Defined Under Namespace
Class Method Summary collapse
-
.for(*methods) ⇒ Module
Generates a module that passes a block to methods that either unwraps a single-valued monadic value or halts the execution.
- .included(base) ⇒ Object private
Class Method Details
.for(*methods) ⇒ Module
Generates a module that passes a block to methods that either unwraps a single-valued monadic value or halts the execution.
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/dry/monads/do.rb', line 77 def self.for(*methods) mod = Module.new do methods.each { |method_name| Do.wrap_method(self, method_name) } end Module.new do singleton_class.send(:define_method, :included) do |base| base.prepend(mod) end end end |
.included(base) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
90 91 92 93 94 95 96 |
# File 'lib/dry/monads/do.rb', line 90 def self.included(base) super # Actually mixes in Do::All require 'dry/monads/do/all' base.include All end |