Class: Social::Network::Base

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/social/network/base.rb

Direct Known Subclasses

Ok, Stub, Vk

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root, list, params = nil) ⇒ Base

Returns a new instance of Base.



12
13
14
15
# File 'lib/social/network/base.rb', line 12

def initialize(root, list, params = nil)
  init_params(params)
  init_graph_for(root, list)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



7
8
9
10
# File 'lib/social/network/base.rb', line 7

def method_missing(name, *args)
  return @graph[name] if @graph && @graph[name]
  super
end

Instance Attribute Details

#graphObject (readonly)

Returns the value of attribute graph.



5
6
7
# File 'lib/social/network/base.rb', line 5

def graph
  @graph
end

Instance Method Details

#configObject



26
27
28
29
# File 'lib/social/network/base.rb', line 26

def config
  reload_config if @config.nil?
  @config
end

#param(key) ⇒ Object



39
40
41
# File 'lib/social/network/base.rb', line 39

def param(key)
  @params[key]
end

#paramsObject



31
32
33
# File 'lib/social/network/base.rb', line 31

def params
  @params
end

#params=(params) ⇒ Object



35
36
37
# File 'lib/social/network/base.rb', line 35

def params=(params)
  @params = params.with_indifferent_access
end

#reload_configObject



17
18
19
20
21
22
23
24
# File 'lib/social/network/base.rb', line 17

def reload_config
  if self.params[:config].present?
    @config = self.params[:config]
  else
    provider_type = self.params[:config_provider] || :file
    @config = Social::Config::Provider.factory_data(social_type, provider_type)
  end
end