Class: Giggly::Javascript::Socialize

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/giggly/javascript/socialize.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

#escape_javascript, #include_gigya_api, #javascript, #javascriptify_object, #to_var

Constructor Details

#initialize(config) ⇒ Socialize

Returns a new instance of Socialize.



8
9
10
11
12
13
14
# File 'lib/giggly/javascript/socialize.rb', line 8

def initialize(config)
  @api_key            = config[:api_key]
  @enabled_providers  = array_to_string(config[:enabled_providers])
  @disabled_providers = array_to_string(config[:disabled_providers])
  
  @config = to_config
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



6
7
8
# File 'lib/giggly/javascript/socialize.rb', line 6

def api_key
  @api_key
end

#configObject

Returns the value of attribute config.



6
7
8
# File 'lib/giggly/javascript/socialize.rb', line 6

def config
  @config
end

#disabled_providersObject

Returns the value of attribute disabled_providers.



6
7
8
# File 'lib/giggly/javascript/socialize.rb', line 6

def disabled_providers
  @disabled_providers
end

#enabled_providersObject

Returns the value of attribute enabled_providers.



6
7
8
# File 'lib/giggly/javascript/socialize.rb', line 6

def enabled_providers
  @enabled_providers
end

Instance Method Details

#config_to_js(config_var_name = :gigyaConfig) ⇒ Object

Socialize specific JS methods



26
27
28
# File 'lib/giggly/javascript/socialize.rb', line 26

def config_to_js(config_var_name = :gigyaConfig)
  to_var(config_var_name, to_config)
end

#include_gigya_socialize(js_path = '/javascripts', min = true) ⇒ Object



30
31
32
# File 'lib/giggly/javascript/socialize.rb', line 30

def include_gigya_socialize(js_path = '/javascripts', min = true)
  include_gigya_api(:socialize) + "\n<script type=\"text/javascript\" src=\"#{js_path}/giggly-socialize#{'-min' if min}.js\"></script>"
end

#to_configObject



16
17
18
19
20
21
22
# File 'lib/giggly/javascript/socialize.rb', line 16

def to_config
  {
    'APIKey'            => @api_key,
    'enabledProviders'  => @enabled_providers,
    'disabledProviders' => @disabled_providers
  }.reject { |k,v| v.nil? }
end