Class: Dry::Mutations::Transactions::Wrapper
- Inherits:
-
Object
- Object
- Dry::Mutations::Transactions::Wrapper
- Defined in:
- lib/dry/mutations/transactions/wrapper.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(**params) ⇒ Wrapper
constructor
A new instance of Wrapper.
- #wrap(λ, **params) ⇒ Object
Constructor Details
#initialize(**params) ⇒ Wrapper
Returns a new instance of Wrapper.
5 6 7 8 9 10 11 12 |
# File 'lib/dry/mutations/transactions/wrapper.rb', line 5 def initialize(**params) (@wrappers = params).each do |name, λ| fail ArgumentError, "Wrapper’s constructor requires hash of { name ⇒ λ(proc, value) }" unless name.is_a?(Symbol) && λ.is_a?(Proc) singleton_class.send :define_method, name do |value, naked| -> { λ.(value, naked.()) } end end end |
Instance Method Details
#wrap(λ, **params) ⇒ Object
14 15 |
# File 'lib/dry/mutations/transactions/wrapper.rb', line 14 def wrap λ, **params end |