Sha256: 894439f8842680ddd46900205e24f361b60b136df1dc16fcba7cdcba2051203b

Contents?: true

Size: 743 Bytes

Versions: 6

Compression:

Stored size: 743 Bytes

Contents

require "active_support/lazy_load_hooks"
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 = ActiveRecord::Base.turntable_config_file, env = (defined?(Rails) ? Rails.env : "development"))
      instance.load!(config_file, env)
    end

    def load!(config_file, env)
      @config = YAML.load(ERB.new(IO.read(config_file)).result).with_indifferent_access[env]
      ActiveSupport.run_load_hooks(:turntable_config_loaded, ActiveRecord::Base)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
activerecord-turntable-3.1.0 lib/active_record/turntable/config.rb
activerecord-turntable-3.0.1 lib/active_record/turntable/config.rb
activerecord-turntable-3.0.0 lib/active_record/turntable/config.rb
activerecord-turntable-3.0.0.alpha3 lib/active_record/turntable/config.rb
activerecord-turntable-3.0.0.alpha2 lib/active_record/turntable/config.rb
activerecord-turntable-3.0.0.alpha1 lib/active_record/turntable/config.rb