Sha256: 9ebc5cedd0177ca4a6caebbc9d6466c3181979b33d904cc3c01414e0e28c943c

Contents?: true

Size: 1.26 KB

Versions: 20

Compression:

Stored size: 1.26 KB

Contents

module Amee
  class Config
    class << self
      attr_accessor :configuration
      
      def defaults
        @defaults ||= {
          :cache => true,
          :cache_store => Moneta::Memory, 
          :expires_in => 60*60*24,
          :server => "stage.amee.com",
          :auth_path => "/auth",
          :accept => "application/json",
          :logging => true
        }
      end
    
      # yields the configuration
      #
      # @example
      #   Amee::Config.set |config| do
      #     config[:server] = "dev.aimee.com"
      #   end
      #
      # @return nil
      def set
        @configuration ||= defaults
        yield @configuration
        nil
      end
    

      def key?(key)
        (@configuration ||= defaults).key?(key)
      end
    
      # Retrieve the value from the config
      #
      # @param [Object] key the key to return the value from 
      #
      # @return [Object]
      def [](key)
        (@configuration ||= defaults)[key]
      end
    
      # sets the value of the config
      def []=(key, val)
        (@configuration ||= defaults)[key] = val
      end
    
      # deletes the value from the config
      def delete(key)
        (@configuration ||= defaults).delete(key)
      end
      
    end
    
  end # Config
end # Amee

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
hookercookerman-amee-0.0.2 lib/amee/config.rb
hookercookerman-amee-0.0.3 lib/amee/config.rb
hookercookerman-amee-0.0.4 lib/amee/config.rb
hookercookerman-amee-0.0.5 lib/amee/config.rb
hookercookerman-amee-0.0.6 lib/amee/config.rb
hookercookerman-amee-0.0.7 lib/amee/config.rb
hookercookerman-amee-0.0.8 lib/amee/config.rb
hookercookerman-amee-0.0.9 lib/amee/config.rb
hookercookerman-amee-0.1.0 lib/amee/config.rb
hookercookerman-amee-0.1.1 lib/amee/config.rb
hookercookerman-amee-0.1.2 lib/amee/config.rb
hookercookerman-amee-0.1.3 lib/amee/config.rb
hookercookerman-amee-0.1.4 lib/amee/config.rb
hookercookerman-amee-0.1.5 lib/amee/config.rb
hookercookerman-amee-0.1.6 lib/amee/config.rb
hookercookerman-amee-0.1.8 lib/amee/config.rb
hookercookerman-amee-0.1.9 lib/amee/config.rb
hookercookerman-amee-0.2.0 lib/amee/config.rb
hookercookerman-amee-0.2.1 lib/amee/config.rb
hookercookerman-amee-0.6.0 lib/amee/config.rb