Class: Lab42::DataClass::Constraints::AttributeSetters::PairOfAttributeSetter

Inherits:
Object
  • Object
show all
Includes:
AttributeSetter
Defined in:
lib/lab42/data_class/constraints/attribute_setters/pair_of_attribute_setter.rb

Instance Attribute Summary

Attributes included from AttributeSetter

#attribute, #constraint, #instance, #return_setter

Instance Method Summary collapse

Instance Method Details

#first_element(value) ⇒ Object



11
12
13
14
15
16
# File 'lib/lab42/data_class/constraints/attribute_setters/pair_of_attribute_setter.rb', line 11

def first_element(value)
  constraint.constraint.first.(value) or raise ConstraintError,
                                               "cannot set value #{value} in set(#{attribute}).first_element"

  _set_attr!(_value.set_first(value))
end

#second_element(value) ⇒ Object



18
19
20
21
22
# File 'lib/lab42/data_class/constraints/attribute_setters/pair_of_attribute_setter.rb', line 18

def second_element(value)
  constraint.constraint.last.(value) or raise ConstraintError,
                                              "cannot set value #{value} in set(#{attribute}).second_element"
  _set_attr!(_value.set_second(value))
end