Class: Authorize::Graph::Factory

Inherits:
Redis::Factory show all
Defined in:
lib/authorize/graph/factory.rb

Instance Attribute Summary

Attributes inherited from Redis::Factory

#db

Instance Method Summary collapse

Methods inherited from Redis::Factory

#array, build, #hash, #initialize, #namespace, #set, #string

Constructor Details

This class inherits a constructor from Authorize::Redis::Factory

Instance Method Details

#directed_graph(name, value = Set[], options = {}, &block) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/authorize/graph/factory.rb', line 8

def directed_graph(name, value = Set[], options = {}, &block)
  options = {:edge_ids => ::Set[]}.merge(options)
  obj = set(name, value) do
    set('edge_ids', options[:edge_ids])
    yield if block_given?
  end
  DirectedGraph.load(obj.id)
end

#edge(name, value = {}, options = {}, &block) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/authorize/graph/factory.rb', line 28

def edge(name, value = {}, options = {}, &block)
  options = {:l_id => nil, :r_id => nil}.merge(options)
  obj = hash(name, value) do
    string(:l_id, options[:l_id])
    string(:r_id, options[:r_id])
    yield if block_given?
  end
  Edge.load(obj.id)
end

#vertex(name, value = {}, options = {}, &block) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/authorize/graph/factory.rb', line 17

def vertex(name, value = {}, options = {}, &block)
  options = {:edge_ids => ::Set[], :inbound_edge_ids => ::Set[]}.merge(options)
  obj = hash(name, value) do
    string('_', nil)
    set('edge_ids', options[:edge_ids])
    set('inbound_edge_ids', options[:inbound_edge_ids])
    yield if block_given?
  end
  Vertex.load(obj.id)
end