Class: ActiveRecord::Base::ConnectionSpecification::Resolver

Inherits:
Object
  • Object
show all
Defined in:
activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb

Overview

Builds a ConnectionSpecification from user input

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, configurations) ⇒ Resolver

Returns a new instance of Resolver


16
17
18
19
# File 'activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb', line 16

def initialize(config, configurations)
  @config         = config
  @configurations = configurations
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config


14
15
16
# File 'activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb', line 14

def config
  @config
end

#configurationsObject (readonly)

Returns the value of attribute configurations


14
15
16
# File 'activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb', line 14

def configurations
  @configurations
end

#klassObject (readonly)

Returns the value of attribute klass


14
15
16
# File 'activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb', line 14

def klass
  @klass
end

Instance Method Details

#specObject


21
22
23
24
25
26
27
28
29
30
31
# File 'activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb', line 21

def spec
  case config
  when nil
    raise AdapterNotSpecified unless defined?(Rails.env)
    resolve_string_connection Rails.env
  when Symbol, String
    resolve_string_connection config.to_s
  when Hash
    resolve_hash_connection config
  end
end