Class: Remap::Contract

Inherits:
Dry::Validation::Contract
  • Object
show all
Defined in:
lib/remap/contract.rb

Class Method Summary collapse

Class Method Details

.call(rules:, options:, contract:, attributes:) ⇒ Contract

Constructs a contract used to validate mapper input

Parameters:

  • rules (Array<Proc>)
  • options (Hash)
  • contract (Proc)
  • attributes (Hash)

Returns:



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/remap/contract.rb', line 13

def self.call(rules:, options:, contract:, attributes:)
  Class.new(self) do
    rules.each do |rule|
      instance_exec(&rule)
    end

    options.each do |option|
      instance_exec(&option)
    end

    schema(contract)
  end.new(**attributes)
end