Class: SocialFramework::NetworkHelper::GraphContext

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/social_framework/network_helper.rb

Overview

Used to define the GraphStrategy class

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#graphObject

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