Module: Neo4j::Embedded::Property

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

Overview

TODO code duplication with the Neo4j::PropertyContainer, This module should extend that module by adding transaction around methods

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



12
13
14
15
# File 'lib/neo4j-embedded/property.rb', line 12

def [](key)
  return nil unless has_property?(key.to_s)
  val = 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 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



27
28
29
# File 'lib/neo4j-embedded/property.rb', line 27

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

#_update_props(hash) ⇒ Object



50
51
52
53
# File 'lib/neo4j-embedded/property.rb', line 50

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

#neo_idObject



60
61
62
# File 'lib/neo4j-embedded/property.rb', line 60

def neo_id
  get_id
end

#propsObject



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

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

#props=(hash) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/neo4j-embedded/property.rb', line 41

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

#refreshObject



64
65
66
# File 'lib/neo4j-embedded/property.rb', line 64

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

#update_props(hash) ⇒ Object



55
56
57
# File 'lib/neo4j-embedded/property.rb', line 55

def update_props(hash)
  _update_props(hash)
end