Sha256: 42ce5cd10a5dace57a435a60884595c959b91a27ba6ca1acd1d7721b09aebd00

Contents?: true

Size: 752 Bytes

Versions: 5

Compression:

Stored size: 752 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'}

      if defined? Rails
        if File.exists? "#{Rails.root}/config/waffle.yml"
          loaded_config = YAML.load_file("#{Rails.root}/config/waffle.yml")

          if loaded_config[Rails.env]
            @config_hash.merge! loaded_config[Rails.env]
          end
        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

5 entries across 5 versions & 1 rubygems

Version Path
waffle-0.3.4 lib/waffle/config.rb
waffle-0.3.3 lib/waffle/config.rb
waffle-0.3.2 lib/waffle/config.rb
waffle-0.3.1 lib/waffle/config.rb
waffle-0.2.2 lib/waffle/config.rb