Module: N4j::Node::AutoRelate::ClassMethods
- Defined in:
- lib/n4j/auto_relate.rb
Instance Method Summary collapse
- #create_root_node ⇒ Object
- #follow_path_from_root ⇒ Object
- #model_root ⇒ Object
- #model_root_name ⇒ Object
Instance Method Details
#create_root_node ⇒ Object
28 29 30 31 32 33 |
# File 'lib/n4j/auto_relate.rb', line 28 def create_root_node node = RootNode.new({:name => model_name.human}) node.new_relationships << GenericRelationship.new(:start => service_root, :end => node, :type => "#{model_root_name}") node.save node end |
#follow_path_from_root ⇒ Object
24 25 26 |
# File 'lib/n4j/auto_relate.rb', line 24 def follow_path_from_root service_root.relationships('outgoing_relationships', model_root_name).first.try(:end) end |
#model_root ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/n4j/auto_relate.rb', line 10 def model_root # Turned off cache here until I can figure out how to keep this from messing with tests. # root = instance_variable_get("@#{model_root_name}") # return root if root root = follow_path_from_root || create_root_node instance_variable_set("@#{model_root_name}", root) end |
#model_root_name ⇒ Object
19 20 21 22 |
# File 'lib/n4j/auto_relate.rb', line 19 def model_root_name variable_name = model_name.param_key model_root_name = "#{variable_name}_root" end |