Class: RailsMultisite::ConnectionManagement::ConnectionSpecification
- Inherits:
-
Object
- Object
- RailsMultisite::ConnectionManagement::ConnectionSpecification
- Defined in:
- lib/rails_multisite/connection_management/connection_specification.rb
Instance Attribute Summary collapse
-
#spec ⇒ Object
readonly
Returns the value of attribute spec.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(spec) ⇒ ConnectionSpecification
constructor
A new instance of ConnectionSpecification.
- #name ⇒ Object
- #to_hash ⇒ Object (also: #config)
Constructor Details
#initialize(spec) ⇒ ConnectionSpecification
23 24 25 |
# File 'lib/rails_multisite/connection_management/connection_specification.rb', line 23 def initialize(spec) @spec = spec end |
Instance Attribute Details
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
21 22 23 |
# File 'lib/rails_multisite/connection_management/connection_specification.rb', line 21 def spec @spec end |
Class Method Details
.current ⇒ Object
7 8 9 |
# File 'lib/rails_multisite/connection_management/connection_specification.rb', line 7 def current new(ActiveRecord::Base.connection_pool.db_config) end |
.db_spec_cache(configs) ⇒ Object
11 12 13 14 |
# File 'lib/rails_multisite/connection_management/connection_specification.rb', line 11 def db_spec_cache(configs) resolve_configs = ActiveRecord::DatabaseConfigurations.new(configs) configs.map { |k, _| [k, new(resolve_configs.resolve(k.to_sym))] }.to_h end |
.default ⇒ Object
16 17 18 |
# File 'lib/rails_multisite/connection_management/connection_specification.rb', line 16 def default new(ActiveRecord::Base.configurations.resolve(Rails.env.to_sym)) end |
Instance Method Details
#name ⇒ Object
27 28 29 |
# File 'lib/rails_multisite/connection_management/connection_specification.rb', line 27 def name spec.env_name end |
#to_hash ⇒ Object Also known as: config
31 32 33 |
# File 'lib/rails_multisite/connection_management/connection_specification.rb', line 31 def to_hash spec.configuration_hash end |