Class: StatusPage::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/status-page/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



6
7
8
9
# File 'lib/status-page/configuration.rb', line 6

def initialize
  @providers = Set.new
  @interval = 10
end

Instance Attribute Details

#basic_auth_credentialsObject

Returns the value of attribute basic_auth_credentials.



3
4
5
# File 'lib/status-page/configuration.rb', line 3

def basic_auth_credentials
  @basic_auth_credentials
end

#error_callbackObject

Returns the value of attribute error_callback.



3
4
5
# File 'lib/status-page/configuration.rb', line 3

def error_callback
  @error_callback
end

#intervalObject

Returns the value of attribute interval.



3
4
5
# File 'lib/status-page/configuration.rb', line 3

def interval
  @interval
end

#providersObject (readonly)

Returns the value of attribute providers.



4
5
6
# File 'lib/status-page/configuration.rb', line 4

def providers
  @providers
end

Instance Method Details

#add_custom_service(custom_service_class) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/status-page/configuration.rb', line 22

def add_custom_service(custom_service_class)
  unless custom_service_class < StatusPage::Services::Base
    raise ArgumentError.new 'custom provider class must implement '\
      'StatusPage::Services::Base'
  end

  add_service(custom_service_class)
end

#use(service_name, opts = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/status-page/configuration.rb', line 11

def use(service_name, opts = {})
  require "status-page/services/#{service_name}"
  klass = "StatusPage::Services::#{service_name.capitalize}".constantize
  if klass.respond_to?(:configurable?) && klass.configurable?
    opts.each_key do |key|
      klass.config.send("#{key}=", opts[key])
    end
  end
  add_service(klass)
end