Module: OpenActive::Concerns::TypeChecker::ClassMethods

Defined in:
lib/openactive/concerns/type_checker.rb

Instance Method Summary collapse

Instance Method Details

#check_types(*args) ⇒ Object



18
19
20
# File 'lib/openactive/concerns/type_checker.rb', line 18

def check_types(*args)
  self.class.check_types(*args)
end

#validate_property(meth, types:) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/openactive/concerns/type_checker.rb', line 9

def validate_property(meth, types:)
  type_validation_module.define_method "#{meth}=" do |value|
    result = check_types(value, types: types)
    super(result)
  rescue StandardError => e
    raise $ERROR_INFO, "error setting field \"#{meth}\"", $ERROR_INFO.backtrace
  end
end