Class: ActiveNode::Graph::Builder

Inherits:
Object
  • Object
show all
Includes:
Neography::Rest::Helpers
Defined in:
lib/active_node/graph/builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, *includes) ⇒ Builder

Returns a new instance of Builder.



8
9
10
11
12
13
14
15
16
# File 'lib/active_node/graph/builder.rb', line 8

def initialize klass, *includes
  @klass = klass if klass < ActiveNode::Base
  @matches = []
  @reflections =[]
  @object_cache = {}
  @relationship_cache = {}
  @loaded_assoc_cache = {}
  parse_paths(:n0, klass, includes)
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



6
7
8
# File 'lib/active_node/graph/builder.rb', line 6

def klass
  @klass
end

#matchesObject (readonly)

Returns the value of attribute matches.



6
7
8
# File 'lib/active_node/graph/builder.rb', line 6

def matches
  @matches
end

#reflectionsObject (readonly)

Returns the value of attribute reflections.



6
7
8
# File 'lib/active_node/graph/builder.rb', line 6

def reflections
  @reflections
end

Instance Method Details

#build(*objects) ⇒ Object



18
19
20
21
22
# File 'lib/active_node/graph/builder.rb', line 18

def build *objects
  ids = objects.map { |o| o.is_a?(ActiveNode::Base) ? o.id.tap { |id| @object_cache[id]=o } : extract_id(o) }
  parse_results execute(ids.compact)
  @object_cache.slice(*ids).values
end