Sha256: ff7218609264244affd38863a543a9f722bb9bb97c7007f79e0c3a569f8295e7

Contents?: true

Size: 859 Bytes

Versions: 1

Compression:

Stored size: 859 Bytes

Contents

require 'singleton'
require 'yaml'

module Waffle
  class Config
    include Singleton

    attr_reader :config_hash

    def initialize
      @config_hash = {'transport' => 'rabbitmq', 'url' => nil, 'encoder' => 'json'}

      filename = "config/waffle.yml"

      if defined? Rails
        fielname = "#{Rails.root}/config/waffle.yml"
      end

      if File.exists?(filename)
        loaded_config = YAML.load_file filename

        if defined?(Rails) && loaded_config[Rails.env]
          @config_hash.merge! loaded_config[Rails.env]
        else
          @config_hash.merge! loaded_config
        end
      end

    end

    class << self

      def method_missing(m, *args, &block)
        if self.instance.config_hash.has_key?(m.to_s)
          self.instance.config_hash[m.to_s]
        else
          super
        end
      end

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
waffle-0.3.5 lib/waffle/config.rb