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
User
Root user to mount graphattributes
Array
Attributes will be added in vertexrelationships
-
Array
labels 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
Hash
with keys and values to comparesearch_in_progress
Boolean
to continue if true or start a new searchelements_number
-
Integer
to limit max search result Returns Hash with users and events 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
Array
labels to find relationships, can be multiple in array or just one in a simple Stringamount_relationships
-
Integer
quantity of relationships to suggest a new relationship ReturnsArray
with users to suggestions.
- Suggest relationships to root ====== Params:
Constructor Details
#initialize(id, graph_strategy = GraphStrategyDefault, elements_factory = ElementsFactoryDefault) ⇒ GraphContext
Initialize the GraphStrategy class
441 442 443 |
# File 'app/helpers/social_framework/network_helper.rb', line 441 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.
438 439 440 |
# File 'app/helpers/social_framework/network_helper.rb', line 438 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
-
User
Root user to mount graph attributes
-
Array
Attributes will be added in vertex relationships
-
Array
labels 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
451 452 453 |
# File 'app/helpers/social_framework/network_helper.rb', line 451 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
-
Hash
with keys and values to compare search_in_progress
-
Boolean
to continue if true or start a new search elements_number
-
Integer
to limit max search result
Returns Hash with users and events found
461 462 463 |
# File 'app/helpers/social_framework/network_helper.rb', line 461 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
-
Array
labels to find relationships, can be multiple in array or just one in a simple String amount_relationships
-
Integer
quantity of relationships to suggest a new relationship
Returns Array
with users to suggestions
470 471 472 473 |
# File 'app/helpers/social_framework/network_helper.rb', line 470 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 |