Class: Talkable::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/talkable/configuration.rb

Defined Under Namespace

Classes: UnknownOptionError

Constant Summary collapse

DEFAULT_SERVER =
"https://www.talkable.com".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



13
14
15
16
17
# File 'lib/talkable/configuration.rb', line 13

def initialize
  self.site_slug  = ENV["TALKABLE_SITE_SLUG"]
  self.api_key    = ENV["TALKABLE_API_KEY"]
  self.server     = DEFAULT_SERVER
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



6
7
8
# File 'lib/talkable/configuration.rb', line 6

def api_key
  @api_key
end

#js_integration_libraryObject

Returns the value of attribute js_integration_library.



8
9
10
# File 'lib/talkable/configuration.rb', line 8

def js_integration_library
  @js_integration_library
end

#serverObject

Returns the value of attribute server.



7
8
9
# File 'lib/talkable/configuration.rb', line 7

def server
  @server
end

#site_slugObject

Returns the value of attribute site_slug.



5
6
7
# File 'lib/talkable/configuration.rb', line 5

def site_slug
  @site_slug
end

Instance Method Details

#apply(config) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/talkable/configuration.rb', line 19

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