Module: ActiveRecord::Honeycomb
- Defined in:
- lib/active_record/honeycomb.rb,
lib/active_record/honeycomb/version.rb,
lib/activerecord-honeycomb/auto_install.rb
Defined Under Namespace
Modules: AutoInstall
Constant Summary collapse
- GEM_NAME =
'activerecord-honeycomb'
- VERSION =
'0.4.0'
Class Method Summary collapse
Class Method Details
.munge_config(config, client: nil, logger: nil) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/active_record/honeycomb.rb', line 6 def munge_config(config, client: nil, logger: nil) config = resolve_config(config) munged = config.merge( 'adapter' => 'honeycomb', 'real_adapter' => config.fetch('adapter'), ) munged['honeycomb_client'] = client if client munged['honeycomb_logger'] = logger if logger logger.debug "#{self.name}: injected HoneycombAdapter config, original adapter was #{munged['real_adapter'].inspect}" if logger munged end |
.resolve_config(config) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/active_record/honeycomb.rb', line 19 def resolve_config(config) # ActiveRecord allows `config` to be a hash, an URL or a Symbol (the # latter representing a key into ActiveRecord::Base.configurations, # initialized elsewhere) - or even `nil` (in which case it checks the # RAILS_ENV global and then falls back to the Symbol path). Rather than # handle this mess, we use the same mechanism as # ActiveRecord::Base.establish_connection to resolve it into a hash so # we can munge it: see # https://github.com/rails/rails/blob/9700dac/activerecord/lib/active_record/connection_handling.rb#L56-L57 resolver = ::ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver.new(::ActiveRecord::Base.configurations) resolver.resolve(config) end |