Class: SocialFramework::NetworkHelper::GraphContext
- Inherits:
-
Object
- Object
- SocialFramework::NetworkHelper::GraphContext
- Defined in:
- app/helpers/social_framework/network_helper.rb
Overview
Used to define the GraphStrategy class
Instance Attribute Summary collapse
-
#graph ⇒ Object
Returns the value of attribute graph.
Instance Method Summary collapse
-
#build(root, attributes = SocialFramework.attributes_to_build_graph, relationships = "all") ⇒ Object
- Mount a graph from an user ====== Params:
root UserRoot user to mount graphattributesArrayAttributes will be added in vertexrelationships-
Arraylabels to find relationships, can be multiple in array or just one in a simple String, default is “all” thats represents all relationships existing Returns The graph mounted.
- Mount a graph from an user ====== Params:
-
#initialize(id, graph_strategy = GraphStrategyDefault, elements_factory = ElementsFactoryDefault) ⇒ GraphContext
constructor
Initialize the GraphStrategy class.
-
#search(map, search_in_progress = false, elements_number = SocialFramework.elements_number_to_search) ⇒ Object
- Search users with values specified in a map ====== Params:
map Hashwith keys and values to comparesearch_in_progressBooleanto continue if true or start a new searchelements_number-
Integerto limit max search result Returns Set with users found.
- Search users with values specified in a map ====== Params:
-
#suggest_relationships(type_relationships = SocialFramework.relationship_type_to_suggest, amount_relationships = SocialFramework.amount_relationship_to_suggest) ⇒ Object
- Suggest relationships to root ====== Params:
type_relationships Arraylabels to find relationships, can be multiple in array or just one in a simple Stringamount_relationships-
Integerquantity of relationships to suggest a new relationship ReturnsArraywith the vertices to suggestions.
- Suggest relationships to root ====== Params:
Constructor Details
#initialize(id, graph_strategy = GraphStrategyDefault, elements_factory = ElementsFactoryDefault) ⇒ GraphContext
Initialize the GraphStrategy class
424 425 426 |
# File 'app/helpers/social_framework/network_helper.rb', line 424 def initialize id, graph_strategy = GraphStrategyDefault, elements_factory = ElementsFactoryDefault @graph = graph_strategy.get_instance id, elements_factory end |
Instance Attribute Details
#graph ⇒ Object
Returns the value of attribute graph.
421 422 423 |
# File 'app/helpers/social_framework/network_helper.rb', line 421 def graph @graph end |
Instance Method Details
#build(root, attributes = SocialFramework.attributes_to_build_graph, relationships = "all") ⇒ Object
Mount a graph from an user
Params:
root-
UserRoot user to mount graph attributes-
ArrayAttributes will be added in vertex relationships-
Arraylabels to find relationships, can be multiple in array or just one in a simple String, default is “all” thats represents all relationships existing
Returns The graph mounted
434 435 436 |
# File 'app/helpers/social_framework/network_helper.rb', line 434 def build(root, attributes = SocialFramework.attributes_to_build_graph, relationships = "all") @graph.build(root, attributes, relationships) end |
#search(map, search_in_progress = false, elements_number = SocialFramework.elements_number_to_search) ⇒ Object
Search users with values specified in a map
Params:
map-
Hashwith keys and values to compare search_in_progress-
Booleanto continue if true or start a new search elements_number-
Integerto limit max search result
Returns Set with users found
444 445 446 |
# File 'app/helpers/social_framework/network_helper.rb', line 444 def search(map, search_in_progress = false, elements_number = SocialFramework.elements_number_to_search) @graph.search(map, search_in_progress, elements_number) end |
#suggest_relationships(type_relationships = SocialFramework.relationship_type_to_suggest, amount_relationships = SocialFramework.amount_relationship_to_suggest) ⇒ Object
Suggest relationships to root
Params:
type_relationships-
Arraylabels to find relationships, can be multiple in array or just one in a simple String amount_relationships-
Integerquantity of relationships to suggest a new relationship
Returns Array with the vertices to suggestions
453 454 455 456 |
# File 'app/helpers/social_framework/network_helper.rb', line 453 def suggest_relationships(type_relationships = SocialFramework.relationship_type_to_suggest, amount_relationships = SocialFramework.amount_relationship_to_suggest) @graph.suggest_relationships(type_relationships, amount_relationships) end |