Module: Lab42::DataClass::Proxy::Constraints
- Included in:
- Lab42::DataClass::Proxy
- Defined in:
- lib/lab42/data_class/proxy/constraints.rb,
lib/lab42/data_class/proxy/constraints/maker.rb
Defined Under Namespace
Modules: Maker
Instance Method Summary collapse
Instance Method Details
#check_constraints_against_defaults ⇒ Object
8 9 10 11 12 13 |
# File 'lib/lab42/data_class/proxy/constraints.rb', line 8 def check_constraints_against_defaults errors = constraints .flat_map(&_check_constraint_against_default) .compact raise ConstraintError, errors.join("\n\n") unless errors.empty? end |
#define_constraints(constraints) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/lab42/data_class/proxy/constraints.rb', line 15 def define_constraints(constraints) errors = constraints.map(&_define_constraint).compact unless errors.empty? raise UndefinedAttributeError, "constraints cannot be defined for undefined attributes #{errors.inspect}" end check_constraints_against_defaults end |