Class: Dry::Mutations::Transactions::Wrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/mutations/transactions/wrapper.rb

Overview

:nodoc:

Direct Known Subclasses

Options

Instance Method Summary collapse

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