Class: Restfulie::Client::Configuration
- Inherits:
-
Hash
- Object
- Hash
- Restfulie::Client::Configuration
- Defined in:
- lib/restfulie/client/configuration.rb
Overview
Use this class to configure the entry point and other relevant behaviors related to accessing or interacting with resources
The available options are:
-
:entry_point
- The URI for an entry point, such as resource.entrypoint.com/post -
:representations
- 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'
Constant Summary collapse
- @@default_configuration =
{ :entry_point => '', :representations => {} }
Instance Attribute Summary collapse
-
#environment ⇒ Object
the current environment.
Instance Method Summary collapse
-
#[](key) ⇒ Object
access (key) configuration value.
-
#[]=(key, value) ⇒ Object
store on (key) configuration the value.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #method_missing(name, *args, &block) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
31 32 33 34 |
# File 'lib/restfulie/client/configuration.rb', line 31 def initialize super self.environment = :development end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/restfulie/client/configuration.rb', line 56 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 |
Instance Attribute Details
#environment ⇒ Object
the current environment
24 25 26 |
# File 'lib/restfulie/client/configuration.rb', line 24 def environment @environment end |
Instance Method Details
#[](key) ⇒ Object
access (key) configuration value
47 48 49 |
# File 'lib/restfulie/client/configuration.rb', line 47 def [](key) fetch(@environment)[key] end |
#[]=(key, value) ⇒ Object
store on (key) configuration the value
52 53 54 |
# File 'lib/restfulie/client/configuration.rb', line 52 def []=(key,value) fetch(@environment)[key] = value end |