Module: ApacheAge::Validators::ExpectedNodeType

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

Instance Method Summary collapse

Instance Method Details

#attribute(attribute_name, type_symbol) ⇒ Object



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

def
  # Register the AGE types vertex_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