Class: Slack::Notifier::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/slack-notifier/config.rb

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



5
6
7
8
9
10
11
12
13
14
# File 'lib/slack-notifier/config.rb', line 5

def initialize
  @http_client = Util::HTTPClient
  @defaults    = {}
  @middleware  = [
    :format_message,
    :format_attachments,
    :at,
    :channels,
  ]
end

Instance Method Details

#defaults(new_defaults = nil) ⇒ Object

Raises:

  • (ArgumentError)


23
24
25
26
27
28
# File 'lib/slack-notifier/config.rb', line 23

def defaults new_defaults=nil
  return @defaults if new_defaults.nil?
  raise ArgumentError, "the defaults must be a Hash" unless new_defaults.is_a?(Hash)

  @defaults = new_defaults
end

#http_client(client = nil) ⇒ Object

Raises:

  • (ArgumentError)


16
17
18
19
20
21
# File 'lib/slack-notifier/config.rb', line 16

def http_client client=nil
  return @http_client if client.nil?
  raise ArgumentError, "the http client must respond to ::post" unless client.respond_to?(:post)

  @http_client = client
end

#middleware(*args) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/slack-notifier/config.rb', line 30

def middleware *args
  return @middleware if args.empty?

  @middleware =
    if args.length == 1 && args.first.is_a?(Array) || args.first.is_a?(Hash)
      args.first
    else
      args
    end
end