Sha256: a6528574ceb9292a2a5a8d519f60538bed0784c889df1681956e68c90b667c6f

Contents?: true

Size: 1.02 KB

Versions: 8

Compression:

Stored size: 1.02 KB

Contents

# TODO code duplication with the Neo4j::PropertyContainer,
# This module should extend that module by adding transaction around methods
module Neo4j::Embedded::Property
  include Neo4j::PropertyValidator
  include Neo4j::PropertyContainer
  extend Neo4j::Core::TxMethods

  # inherit the []= method but add auto transaction around it
  tx_methods :[]=

  def [](key)
    return nil unless has_property?(key.to_s)
    get_property(key.to_s)
  end
  tx_methods :[]

  def props
    property_keys.inject({}) do |ret, key|
      ret[key.to_sym] = get_property(key)
      ret
    end
  end
  tx_methods :props


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

  def _update_props(hash)
    hash.each_pair do |k,v|
      if v.nil?
        remove_property(k)
      else
        set_property(k,v)
      end
    end
    hash
  end

  def update_props(hash)
    _update_props(hash)
  end
  tx_methods :update_props

  def neo_id
    get_id
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
neo4j-core-3.0.0.alpha.17 lib/neo4j-embedded/property.rb
neo4j-core-3.0.0.alpha.16 lib/neo4j-embedded/property.rb
neo4j-core-3.0.0.alpha.15 lib/neo4j-embedded/property.rb
neo4j-core-3.0.0.alpha.14 lib/neo4j-embedded/property.rb
neo4j-core-3.0.0.alpha.13 lib/neo4j-embedded/property.rb
neo4j-core-3.0.0.alpha.12 lib/neo4j-embedded/property.rb
neo4j-core-3.0.0.alpha.11 lib/neo4j-embedded/property.rb
neo4j-core-3.0.0.alpha.10 lib/neo4j-embedded/property.rb