class Talkable::Configuration

Constants

DEFAULT_SERVER
DEFAULT_TIMEOUT

Attributes

api_key[RW]
js_integration_library[RW]
open_timeout[RW]
read_timeout[RW]
server[RW]
site_slug[RW]

Public Class Methods

new() click to toggle source
# File lib/talkable/configuration.rb, line 16
def initialize
  apply(default_configuration)
end

Public Instance Methods

apply(config) click to toggle source
# File lib/talkable/configuration.rb, line 20
def apply(config)
  config.each do |key, value|
    if respond_to?("#{key}=")
      public_send("#{key}=", value)
    else
      raise UnknownOptionError.new("There is no `#{key}` option")
    end
  end
end
reset() click to toggle source
# File lib/talkable/configuration.rb, line 34
def reset
  apply(default_configuration)
end
timeout=(sec) click to toggle source
# File lib/talkable/configuration.rb, line 38
def timeout=(sec)
  apply(read_timeout: sec, open_timeout: sec)
end

Private Instance Methods

default_configuration() click to toggle source
# File lib/talkable/configuration.rb, line 48
def default_configuration
  {
    site_slug:              ENV["TALKABLE_SITE_SLUG"],
    api_key:                ENV["TALKABLE_API_KEY"],
    server:                 DEFAULT_SERVER,
    read_timeout:           DEFAULT_TIMEOUT,
    open_timeout:           DEFAULT_TIMEOUT,
    js_integration_library: nil
  }
end
default_js_integration_library() click to toggle source
# File lib/talkable/configuration.rb, line 44
def default_js_integration_library
  "//d2jjzw81hqbuqv.cloudfront.net/integration/clients/#{site_slug}.min.js"
end