Class: Arproxy::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/arproxy/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



6
7
8
# File 'lib/arproxy/config.rb', line 6

def initialize
  @proxies = []
end

Instance Attribute Details

#adapterObject

Returns the value of attribute adapter.



3
4
5
# File 'lib/arproxy/config.rb', line 3

def adapter
  @adapter
end

#loggerObject

Returns the value of attribute logger.



3
4
5
# File 'lib/arproxy/config.rb', line 3

def logger
  @logger
end

#proxiesObject (readonly)

Returns the value of attribute proxies.



4
5
6
# File 'lib/arproxy/config.rb', line 4

def proxies
  @proxies
end

Instance Method Details

#adapter_classObject

Raises:



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/arproxy/config.rb', line 20

def adapter_class
  raise Arproxy::Error, "config.adapter must be set" unless @adapter
  case @adapter
  when String, Symbol
    camelized_adapter_name = @adapter.to_s.split("_").map(&:capitalize).join
    eval "::ActiveRecord::ConnectionAdapters::#{camelized_adapter_name}Adapter"
  when Class
    @adapter
  else
    raise Arproxy::Error, "unexpected config.adapter: #{@adapter}"
  end
end

#plugin(name, *options) ⇒ Object



15
16
17
18
# File 'lib/arproxy/config.rb', line 15

def plugin(name, *options)
  plugin_class = Plugin.get(name)
  use(plugin_class, *options)
end

#use(proxy_class, *options) ⇒ Object



10
11
12
13
# File 'lib/arproxy/config.rb', line 10

def use(proxy_class, *options)
  ::Arproxy.logger.debug("Arproxy: Mounting #{proxy_class.inspect} (#{options.inspect})")
  @proxies << [proxy_class, options]
end