Class: Dry::Schema::TypesMerger::ValueMerger Private

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/schema/types_merger.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(types_merger, op_class, old, new) ⇒ ValueMerger

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.

Returns a new instance of ValueMerger.



21
22
23
24
25
26
# File 'lib/dry/schema/types_merger.rb', line 21

def initialize(types_merger, op_class, old, new)
  @types_merger = types_merger
  @op_class = op_class
  @old = old
  @new = new
end

Instance Attribute Details

#newObject (readonly)

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.



18
19
20
# File 'lib/dry/schema/types_merger.rb', line 18

def new
  @new
end

#oldObject (readonly)

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.



17
18
19
# File 'lib/dry/schema/types_merger.rb', line 17

def old
  @old
end

#op_classObject (readonly)

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.



16
17
18
# File 'lib/dry/schema/types_merger.rb', line 16

def op_class
  @op_class
end

#types_mergerObject (readonly)

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.



15
16
17
# File 'lib/dry/schema/types_merger.rb', line 15

def types_merger
  @types_merger
end

Instance Method Details

#callObject

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.



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/dry/schema/types_merger.rb', line 29

def call
  if op_class <= Dry::Logic::Operations::Or
    merge_or
  elsif op_class <= Dry::Logic::Operations::And
    merge_and
  elsif op_class <= Dry::Logic::Operations::Implication
    merge_implication
  else
    raise ArgumentError, <<~MESSAGE
      Can't merge operations, op_class=#{op_class}
    MESSAGE
  end
end