Module: Neo4j::Embedded::Property

Extended by:
Core::TxMethods
Includes:
PropertyContainer, PropertyValidator
Defined in:
lib/neo4j-embedded/property.rb

Constant Summary

Constants included from PropertyValidator

PropertyValidator::VALID_PROPERTY_VALUE_CLASSES

Instance Method Summary collapse

Methods included from Core::TxMethods

tx_methods

Methods included from PropertyValidator

#valid_property?, #validate_property

Instance Method Details

#[](key) ⇒ Object



14
15
16
17
18
# File 'lib/neo4j-embedded/property.rb', line 14

def [](key)
  return nil unless has_property?(key.to_s)

  to_ruby_property(key.to_s)
end

#[]=(k, v) ⇒ Object

Sets the property of this node. Property keys are always strings. Valid property value types are the primitives: (String, Fixnum, Float, FalseClass, TrueClass) or an array of those primitives.

Gotchas

  • Values in the array must be of the same type.

  • You can not delete or add one item in the array (e.g. person.phones.delete(‘123’)) but instead you must create a new array instead.

Parameters:

  • k (String, Symbol)

    of the property to set

  • v (String, Fixnum, Float, true, false, Array)

    to set



32
33
34
# File 'lib/neo4j-embedded/property.rb', line 32

def []=(k, v)
  to_java_property(k, v)
end

#_update_props(hash) ⇒ Object



53
54
55
# File 'lib/neo4j-embedded/property.rb', line 53

def _update_props(hash)
  hash.each { |k, v| to_java_property(k, v) }
end

#neo_idObject



62
63
64
# File 'lib/neo4j-embedded/property.rb', line 62

def neo_id
  get_id
end

#propsObject



37
38
39
40
41
# File 'lib/neo4j-embedded/property.rb', line 37

def props
  property_keys.each_with_object({}) do |key, ret|
    ret[key.to_sym] = to_ruby_property(key)
  end
end

#props=(hash) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/neo4j-embedded/property.rb', line 44

def props=(hash)
  property_keys.each do |key|
    remove_property(key)
  end
  _update_props(hash)
  hash
end

#refreshObject



66
67
68
# File 'lib/neo4j-embedded/property.rb', line 66

def refresh
  # nothing is needed in the embedded db since we always asks the database
end

#update_props(hash) ⇒ Object



57
58
59
# File 'lib/neo4j-embedded/property.rb', line 57

def update_props(hash)
  _update_props(hash)
end