Class: RubyRest::SimpleConfig
- Inherits:
-
Object
- Object
- RubyRest::SimpleConfig
- Includes:
- Tools
- Defined in:
- lib/rubyrest/config.rb
Overview
This class is meant to be subclassed with customized behaviour that will be invoked by the engine at startup. Subclasses can provide connectivity to popular database frameworks such as ActiveRecord, Sequel or Og.
Example:
module MyService
class Config < RubyRest::SimpleConfig
end
end
Direct Known Subclasses
Constant Summary
Constants included from Tools
Tools::ATOM_DATE_FORMAT, Tools::ERRORS
Instance Method Summary collapse
-
#[](name) ⇒ Object
Returns a given configuration option value.
-
#[]=(name, value) ⇒ Object
Overrides the specified configuration option with its new value.
-
#has(name) ⇒ Object
Returns true if the specified name matches a valid configuration option.
-
#initialize(hash) ⇒ SimpleConfig
constructor
Initializes a new configuration with the specified hash of data.
-
#to_s ⇒ Object
Dumps all the configuration options.
Methods included from Tools
#error, #format_atom_date, #nvl, #parse_atom_date, #to_class, #to_gem_name, #to_module_name
Constructor Details
#initialize(hash) ⇒ SimpleConfig
Initializes a new configuration with the specified hash of data
26 27 28 |
# File 'lib/rubyrest/config.rb', line 26 def initialize( hash ) @hash = hash end |
Instance Method Details
#[](name) ⇒ Object
Returns a given configuration option value
37 38 39 40 |
# File 'lib/rubyrest/config.rb', line 37 def [](name) raise error( 000, name ) if !has( name ) return @hash[ name ] end |
#[]=(name, value) ⇒ Object
Overrides the specified configuration option with its new value
32 33 34 |
# File 'lib/rubyrest/config.rb', line 32 def []=( name, value ) @hash[ name ] = value end |
#has(name) ⇒ Object
Returns true if the specified name matches a valid configuration option
44 45 46 |
# File 'lib/rubyrest/config.rb', line 44 def has( name ) @hash[ name ] != nil end |
#to_s ⇒ Object
Dumps all the configuration options
49 50 51 |
# File 'lib/rubyrest/config.rb', line 49 def to_s @hash.each{ |k,v| puts "key: #{k}, value: #{v}" } end |