module Guacamole::EdgeCollection::ClassMethods
Public Instance Methods
add_edge_definition_to_graph()
click to toggle source
# File lib/guacamole/edge_collection.rb, line 40 def add_edge_definition_to_graph graph.add_edge_definition(collection_name, from: [edge_class.from], to: [edge_class.to]) rescue Ashikawa::Core::ResourceNotFound # FIXME: We just assume this 404 is raised because the edge definition is already created. # But the source of the error could be something else too. Had to be changed as soon # https://github.com/triAGENS/ashikawa-core/issues/136 is done. end
connection()
click to toggle source
# File lib/guacamole/edge_collection.rb, line 32 def connection @connection ||= graph.edge_collection(collection_name) end
edge_class()
click to toggle source
# File lib/guacamole/edge_collection.rb, line 36 def edge_class @edge_class ||= model_class end
mapper_for_start(model)
click to toggle source
# File lib/guacamole/edge_collection.rb, line 77 def mapper_for_start(model) vertex_mapper.find { |mapper| mapper.responsible_for?(model) } end
mapper_for_target(model)
click to toggle source
# File lib/guacamole/edge_collection.rb, line 73 def mapper_for_target(model) vertex_mapper.find { |mapper| !mapper.responsible_for?(model) } end
neighbors(model, direction = :inbound)
click to toggle source
# File lib/guacamole/edge_collection.rb, line 50 def neighbors(model, direction = :inbound) aql_string = <<-AQL FOR n IN GRAPH_NEIGHBORS(@graph, { _key: @model_key }, { direction: @direction, edgeCollectionRestriction: @edge_collection }) RETURN n.vertex AQL bind_parameters = { graph: Guacamole.configuration.graph.name, model_key: model.key, edge_collection: collection_name, direction: direction } options = { return_as: nil, for_in: nil } query = AqlQuery.new(self, mapper_for_target(model), options) query.aql_fragment = aql_string query.bind_parameters = bind_parameters query end
vertex_mapper()
click to toggle source
# File lib/guacamole/edge_collection.rb, line 81 def vertex_mapper [edge_class.from_collection, edge_class.to_collection].map(&:mapper) end