class Dingding::Notifier::Config

Public Class Methods

new() click to toggle source
# File lib/dingding-notifier/config.rb, line 6
def initialize
  @http_client = Util::HTTPClient
  @middleware  = %i[
    format_text
    format_link
    format_markdown
    format_action_card
    format_feed_card
  ]
end

Public Instance Methods

http_client(client=nil) click to toggle source
# File lib/dingding-notifier/config.rb, line 17
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) click to toggle source
# File lib/dingding-notifier/config.rb, line 24
def middleware *args
  args.delete_if{|a| a.nil?}
  return [:format_text] if args.empty? || args.nil?
  
  @middleware =
    if args.length == 1 && args.first.is_a?(Array) || args.first.is_a?(Hash)
      args.first
    else
      args
    end
end