Sha256: 3f6e8951a2dc63623bd6f4c9e79692dddb32a9a185748bac94876a165d10a243

Contents?: true

Size: 558 Bytes

Versions: 5

Compression:

Stored size: 558 Bytes

Contents

require 'active_support/core_ext/hash/indifferent_access'

module ActiveRecord::Turntable
  class Config
    include Singleton

    def self.[](key)
      instance[key]
    end

    def [](key)
      self.class.load!(ActiveRecord::Base.turntable_config_file) unless @config
      @config[key]
    end

    def self.load!(config_file, env = (defined?(Rails) ? Rails.env : 'development'))
      instance.load!(config_file, env)
    end

    def load!(config_file, env)
      @config = YAML.load_file(config_file).with_indifferent_access[env]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
activerecord-turntable-1.1.2 lib/active_record/turntable/config.rb
activerecord-turntable-1.1.1 lib/active_record/turntable/config.rb
activerecord-turntable-1.1.0 lib/active_record/turntable/config.rb
activerecord-turntable-1.0.1 lib/active_record/turntable/config.rb
activerecord-turntable-1.0.0 lib/active_record/turntable/config.rb