Sha256: 2429f588c88b97dca3b4150628f91835e648757a8dfbec8a75cf54af433b61e9
Contents?: true
Size: 815 Bytes
Versions: 3
Compression:
Stored size: 815 Bytes
Contents
require_relative "database_configuration_registry" require "delegate" module Snowglobe class DatabaseConfiguration < SimpleDelegator ENVIRONMENTS = %w(development test production).freeze attr_reader :adapter_class def self.for(database_name, adapter_name) config_class = DatabaseConfigurationRegistry.instance.get(adapter_name) config = config_class.new(database_name) new(config) end def initialize(config) @adapter_class = config.class.to_s.split("::").last super(config) end def to_hash ENVIRONMENTS.each_with_object({}) do |env, config_as_hash| config_as_hash[env] = inner_config_as_hash end end private def inner_config_as_hash { "adapter" => adapter.to_s, "database" => database.to_s } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
snowglobe-0.3.0 | lib/snowglobe/database_configuration.rb |
snowglobe-0.2.0 | lib/snowglobe/database_configuration.rb |
snowglobe-0.1.0 | lib/snowglobe/database_configuration.rb |