class Sailplay::Configuration

Constants

DEFAULT_CONNECTION_OPTIONS
OPTIONS

Attributes

connection_options[RW]
endpoint[RW]

Url prefix for API (defaults to /api)

host[RW]

The host to connect to (defaults to sailplay.ru).

js_api_path[RW]

JS client configuration

js_position[RW]

one of :top_left, :top_right, :center_left, :center_right, :bottom_left, :bottom_right

logger[RW]
port[RW]

The port on which Sailplay API server runs (defaults to 443 for secure connections, 80 for insecure connections).

secure[RW]

true for https connections, false for http connections.

secure?[RW]

true for https connections, false for http connections.

skin[RW]

{

:buttonText => 'Text', :buttonBgGradient => ["#78bb44", "#367300"], :buttonFontSize => '9px',
:picUrl => "http://some.url", :bgColor => '#ffffff', :borderColor => '#ffffff', :textColor => '#300c2f',
:pointsColor => '#c81750', :buttonTextColor => '#ffffff'

}

store_id[RW]
store_key[RW]
store_pin[RW]

Public Class Methods

new() click to toggle source
# File lib/sailplay/configuration.rb, line 51
def initialize
  @host =     'sailplay.ru'
  @secure =   true
  @endpoint = '/api'

  @js_api_path = 'static/js/sailplay.js'
  @js_position = :top_right

  @skin = {}

  @connection_options = DEFAULT_CONNECTION_OPTIONS.dup
end

Public Instance Methods

[](option) click to toggle source

Allows config options to be read like a hash

@param [Symbol] option Key for a given attribute

# File lib/sailplay/configuration.rb, line 67
def [](option)
  send(option)
end
protocol() click to toggle source

Determines whether protocol should be “http” or “https”. @return [String] Returns +“http”+ if you’ve set secure to false in configuration, and +“https”+ otherwise.

# File lib/sailplay/configuration.rb, line 86
def protocol
  if secure?
    'https'
  else
    'http'
  end
end
to_hash() click to toggle source

Returns a hash of all configurable options

# File lib/sailplay/configuration.rb, line 72
def to_hash
  OPTIONS.inject({}) do |hash, option|
    hash[option.to_sym] = self.send(option)
    hash
  end
end

Private Instance Methods

default_port() click to toggle source

Determines what port should we use for sending notices. @return [Fixnum] Returns 443 if you’ve set secure to true in your configuration, and 80 otherwise.

# File lib/sailplay/configuration.rb, line 107
def default_port
  if secure?
    443
  else
    80
  end
end