Class: Slack::Notifier::Config
- Inherits:
-
Object
- Object
- Slack::Notifier::Config
- Defined in:
- lib/slack-notifier/config.rb
Instance Method Summary collapse
- #defaults(new_defaults = nil) ⇒ Object
- #http_client(client = nil) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #middleware(*args) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
5 6 7 8 9 |
# File 'lib/slack-notifier/config.rb', line 5 def initialize @http_client = Util::HTTPClient @defaults = {} @middleware = [:format_message, :format_attachments] end |
Instance Method Details
#defaults(new_defaults = nil) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/slack-notifier/config.rb', line 18 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
11 12 13 14 15 16 |
# File 'lib/slack-notifier/config.rb', line 11 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
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/slack-notifier/config.rb', line 25 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 |