Class: Neo4j::Http::ObjectWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/neo4j/http/object_wrapper.rb

Direct Known Subclasses

Node, Relationship

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label:, primary_key_name: nil, **attributes) ⇒ ObjectWrapper

Returns a new instance of ObjectWrapper.



12
13
14
15
16
17
# File 'lib/neo4j/http/object_wrapper.rb', line 12

def initialize(label:, primary_key_name: nil, **attributes)
  @original_attributes = (attributes || {}).with_indifferent_access
  @attributes = original_attributes.dup.with_indifferent_access
  @key_name = primary_key_name
  @label = label
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/neo4j/http/object_wrapper.rb', line 21

def method_missing(method_name, *args, &block)
  if @original_attributes.has_key?(method_name)
    original_attributes[method_name]
  else
    super
  end
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



6
7
8
# File 'lib/neo4j/http/object_wrapper.rb', line 6

def attributes
  @attributes
end

#key_nameObject (readonly)

Returns the value of attribute key_name.



6
7
8
# File 'lib/neo4j/http/object_wrapper.rb', line 6

def key_name
  @key_name
end

#key_valueObject (readonly)

Returns the value of attribute key_value.



6
7
8
# File 'lib/neo4j/http/object_wrapper.rb', line 6

def key_value
  @key_value
end

#labelObject (readonly)

Returns the value of attribute label.



6
7
8
# File 'lib/neo4j/http/object_wrapper.rb', line 6

def label
  @label
end

#original_attributesObject (readonly)

Returns the value of attribute original_attributes.



6
7
8
# File 'lib/neo4j/http/object_wrapper.rb', line 6

def original_attributes
  @original_attributes
end

Instance Method Details

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/neo4j/http/object_wrapper.rb', line 29

def respond_to_missing?(method_name, include_private = false)
  @original_attributes.has_key?(method_name) || super
end