Module: Graphable::ClassMethods
- Defined in:
- lib/graphable.rb
Instance Method Summary collapse
- #graph_index_name ⇒ Object
- #graph_indexes(*methods) ⇒ Object
- #graph_with(method) ⇒ Object
- #has_edge(hash = {}, &block) ⇒ Object
Instance Method Details
#graph_index_name ⇒ Object
86 87 88 |
# File 'lib/graphable.rb', line 86 def graph_index_name "#{name.downcase.pluralize}_index" end |
#graph_indexes(*methods) ⇒ Object
90 91 92 93 94 |
# File 'lib/graphable.rb', line 90 def graph_indexes(*methods) methods.each do |method| Graphable.register IndexCreator.new(self, method) end end |
#graph_with(method) ⇒ Object
109 110 111 |
# File 'lib/graphable.rb', line 109 def graph_with(method) Graphable.register_object_access_method(self, method) end |
#has_edge(hash = {}, &block) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/graphable.rb', line 96 def has_edge(hash = {}, &block) source_klass = self target_klass = hash[:to] hash[:block] = block if hash.has_key?(:through) Graphable.register EdgeCreator.through(source_klass, target_klass, hash.delete(:through), hash) elsif hash.has_key?(:via) Graphable.register EdgeCreator.via(source_klass, target_klass, hash.delete(:via), hash) else raise "Invalid Edge type, must be :through or :via" end end |