Class: Keymaker::TraversePathRequest

Inherits:
Request
  • Object
show all
Defined in:
lib/keymaker/requests/traverse_path_request.rb

Instance Attribute Summary

Attributes inherited from Request

#config, #opts, #service

Instance Method Summary collapse

Methods inherited from Request

#initialize

Constructor Details

This class inherits a constructor from Keymaker::Request

Instance Method Details

#node_traverse_path(node_id) ⇒ Object



41
42
43
# File 'lib/keymaker/requests/traverse_path_request.rb', line 41

def node_traverse_path(node_id)
  [node_path, node_id.to_s, "traverse", "path"].join("/")
end

#submitObject

POST localhost:7474/db/data/node/9/traverse/path Accept: application/json Content-Type: application/json “order”:“breadth_first”,“uniqueness”:“none”,“return_filter”:{“language”:“builtin”,“name”:“all”}



11
12
13
14
15
16
17
18
19
20
# File 'lib/keymaker/requests/traverse_path_request.rb', line 11

def submit
  service.post(node_traverse_path(opts[:node_id]), traverse_path_properties).on_error do |response|
    case response.status
    when (400..499)
      raise ClientError.new(response, response.body)
    when (500..599)
      raise ServerError.new(response, response.body)
    end
  end
end

#traverse_path_propertiesObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/keymaker/requests/traverse_path_request.rb', line 22

def traverse_path_properties
  # :order - breadth_first or depth_first
  # :relationships - all, in, or out
  #   e.g. [{"type" => "likes", "direction" => "all}]
  # :uniqueness - node_global, none, relationship_global, node_path, or relationship_path
  # :prune_evaluator
  # :return_filter
  # :max_depth

  {}.tap do |properties|
    properties[:order] = opts.fetch(:order, "breadth_first")
    properties[:relationships] = opts.fetch(:relationships, [])
    properties[:uniqueness] = opts.fetch(:uniqueness, "relationship_global")
    properties[:prune_evaluator] = opts[:prune_evaluator] if opts[:prune_evaluator]
    properties[:return_filter] = opts[:return_filter] if opts[:return_filter]
    properties[:max_depth] = opts[:max_depth] if opts[:max_depth]
  end
end