Class: Dry::Types::Sum::Constrained

Inherits:
Dry::Types::Sum show all
Defined in:
lib/dry/types/sum.rb

Instance Attribute Summary

Attributes inherited from Dry::Types::Sum

#left, #right

Attributes included from Options

#options

Instance Method Summary collapse

Methods inherited from Dry::Types::Sum

#default?, #initialize, #maybe?, #name, #primitive?, #try, #valid?

Methods included from Options

#initialize, #meta, #with

Methods included from Builder

#constrained, #constrained_type, #constructor, #default, #enum, #maybe, #optional, #safe, #|

Constructor Details

This class inherits a constructor from Dry::Types::Sum

Instance Method Details

#call(input) ⇒ Object Also known as: []

Parameters:

  • input (Object)

Returns:

  • (Object)

Raises:



30
31
32
33
34
# File 'lib/dry/types/sum.rb', line 30

def call(input)
  try(input) do |result|
    raise ConstraintError.new(result, input)
  end.input
end

#constrained?true

Returns:

  • (true)


23
24
25
# File 'lib/dry/types/sum.rb', line 23

def constrained?
  true
end

#ruleDry::Logic::Rule

Returns:

  • (Dry::Logic::Rule)


18
19
20
# File 'lib/dry/types/sum.rb', line 18

def rule
  left.rule | right.rule
end