Sha256: 0ecafeb54c78f864aaba9aafbc627bf6c6d00114470172819ef0c0207ab1e6f8
Contents?: true
Size: 1.87 KB
Versions: 4
Compression:
Stored size: 1.87 KB
Contents
module Restfulie::Client #:nodoc: # Use this class to configure the entry point and other relevant behaviors related to accessing or interacting with resources # # The available options are: # # * <tt>:entry_point</tt> - The URI for an entry point, such as http://resource.entrypoint.com/post # * <tt>:representations</tt> - Representations. # # You can also store any other custom configuration. # # ==== Example # # configuration = Configuration.new # configuration[:entry_point] = 'http://resource.entrypoint.com/post' # configuration[:entry_point] # => 'http://resource.entrypoint.com/post' # # or you can use: # # configuration.entry_point = 'http://resource.entrypoint.com/post' # configuration.entry_point # => 'http://resource.entrypoint.com/post' class Configuration < ::Hash # the current environment attr_reader :environment @@default_configuration = { :entry_point => '', :representations => {} } def initialize super self.environment = :development end # this will store a new configuration (based on the default) for the environment passed by value. def environment=(value) @environment = value unless has_key?(@environment) dee_clone = Marshal::load(Marshal::dump(@@default_configuration)) store(@environment,dee_clone) end @environment end # access (key) configuration value def [](key) fetch(@environment)[key] end # store on (key) configuration the value def []=(key,value) fetch(@environment)[key] = value end def method_missing(name, *args, &block) method_name = name.to_s if method_name.last == '=' fetch(environment)[method_name.chop.to_sym] = args[0] else value = fetch(environment)[name] value ? value : super end end end end
Version data entries
4 entries across 4 versions & 1 rubygems