Class: Authorize::Graph::DirectedGraph

Inherits:
Graph show all
Defined in:
lib/authorize/graph/directed_graph.rb

Overview

Notes:

Edges are created in the context of a graph in order to allow for graph-specific indexing

Direct Known Subclasses

DirectedAcyclicGraph

Constant Summary

Constants inherited from Redis::Base

Redis::Base::NAMESPACE_SEPARATOR

Instance Attribute Summary

Attributes inherited from Graph

#edge_namespace, #vertex_namespace

Attributes inherited from Redis::Base

#id

Instance Method Summary collapse

Methods inherited from Graph

#edge, #edges, exists?, #traverse, #vertex, #vertex_by_name, #vertices

Methods inherited from Redis::Set

#<<, #__getobj__, #add, #delete, #first, #include?, #sample, #valid?

Methods inherited from Redis::Base

#==, #__getobj__, #_dump, _load, connection, connection_base?, connection_manager, #db, #destroy, #eql?, exists?, #exists?, generate_key, #hash, index, load, load_all, #logger, #method_missing, new, next_counter, #reload, #respond_to?, #subordinate_key, subordinate_key, #to_yaml, #valid?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Authorize::Redis::Base

Instance Method Details

#disjoin(v0, v1) ⇒ Object



19
20
21
22
23
24
# File 'lib/authorize/graph/directed_graph.rb', line 19

def disjoin(v0, v1)
  return unless existing_edge = v0.edges.detect{|e| v1.eql?(e.to)}
  existing_edge.tap do |edge|
    edge.destroy
  end
end

#join(name, v0, v1, properties = {}) ⇒ Object

Find or create a directed edge joining the given vertices



13
14
15
16
17
# File 'lib/authorize/graph/directed_graph.rb', line 13

def join(name, v0, v1, properties = {})
  existing_edge = v0.edges.detect{|e| v1.eql?(e.to)}
  existing_edge.try(:merge, properties)
  existing_edge || edge(name, v0, v1, properties)
end