Module: ApacheAge::NodeTypeValidator

Defined in:
lib/apache_age/validators/node_type_validator.rb

Instance Method Summary collapse

Instance Method Details

#attribute(attribute_name, type_symbol) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/apache_age/validators/node_type_validator.rb', line 3

def
  # Register the AGE typesvertex_attribute(attribute_name, type_symbol, klass)
  attribute attribute_name, type_symbol

  validate do
    value = send(attribute_name)
    unless value.is_a?(klass)
      errors.add(attribute_name, "must be a #{klass.name}")
    end
  end
end