class CottonTail::Configuration

Configuration options

Attributes

connection_args[R]

Public Class Methods

new(middleware: nil) click to toggle source
# File lib/cotton_tail/configuration.rb, line 10
def initialize(middleware: nil)
  @connection_args = nil
  @middleware = middleware
  @user_configs = {}
end

Public Instance Methods

connection_args=(*args, **kwargs) click to toggle source

Sets the RabbitMQ connection params. Arguments are eventually passed to Bunny.new. Any valid params for Bunny.new are accepted.

@see rubybunny.info/articles/connecting.html

# File lib/cotton_tail/configuration.rb, line 20
def connection_args=(*args, **kwargs)
  url, = args
  @connection_args = url ? Bunny::Session.parse_uri(url) : kwargs
end
method_missing(method_id, *arguments, &block) click to toggle source
Calls superclass method
# File lib/cotton_tail/configuration.rb, line 37
def method_missing(method_id, *arguments, &block)
  if user_config? method_id
    @user_configs[method_id]
  elsif setter?(method_id) && arguments.length == 1
    @user_configs[getter_name(method_id)] = arguments.first
  else
    super
  end
end
middleware() { |b| ... } click to toggle source

Modify or retrieve the application middleware stack.

@see github.com/Ibsciss/ruby-middleware

# File lib/cotton_tail/configuration.rb, line 28
def middleware
  return @middleware unless block_given?

  @middleware = ::Middleware::Builder.new do |b|
    b.use @middleware if @middleware
    yield b
  end
end
respond_to_missing?(method_id, include_private = false) click to toggle source
Calls superclass method
# File lib/cotton_tail/configuration.rb, line 47
def respond_to_missing?(method_id, include_private = false)
  user_config?(method_id) || super
end

Private Instance Methods

getter_name(setter) click to toggle source
# File lib/cotton_tail/configuration.rb, line 61
def getter_name(setter)
  setter.to_s.sub('=', '').to_sym
end
setter?(method_id) click to toggle source
# File lib/cotton_tail/configuration.rb, line 53
def setter?(method_id)
  method_id.to_s.end_with? '='
end
user_config?(method_id) click to toggle source
# File lib/cotton_tail/configuration.rb, line 57
def user_config?(method_id)
  @user_configs.key?(method_id)
end