Class: Heroics::Configuration
- Inherits:
-
Object
- Object
- Heroics::Configuration
- Defined in:
- lib/heroics/configuration.rb
Overview
Attempts to load configuration, provides defaults, and provide helpers to access that data
Instance Attribute Summary collapse
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#cache_path ⇒ Object
Returns the value of attribute cache_path.
-
#module_name ⇒ Object
Returns the value of attribute module_name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#schema ⇒ Object
Returns the value of attribute schema.
Class Method Summary collapse
Instance Method Summary collapse
- #headers=(headers) ⇒ Object
-
#initialize {|_self| ... } ⇒ Configuration
constructor
A new instance of Configuration.
- #schema_filepath=(schema_filepath) ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Configuration
Returns a new instance of Configuration.
12 13 14 15 16 17 18 |
# File 'lib/heroics/configuration.rb', line 12 def initialize = {} [:cache] = 'Moneta.new(:Memory)' [:default_headers] = {} yield self if block_given? end |
Instance Attribute Details
#base_url ⇒ Object
Returns the value of attribute base_url.
6 7 8 |
# File 'lib/heroics/configuration.rb', line 6 def base_url @base_url end |
#cache_path ⇒ Object
Returns the value of attribute cache_path.
6 7 8 |
# File 'lib/heroics/configuration.rb', line 6 def cache_path @cache_path end |
#module_name ⇒ Object
Returns the value of attribute module_name.
6 7 8 |
# File 'lib/heroics/configuration.rb', line 6 def module_name @module_name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/heroics/configuration.rb', line 6 def end |
#schema ⇒ Object
Returns the value of attribute schema.
6 7 8 |
# File 'lib/heroics/configuration.rb', line 6 def schema @schema end |
Class Method Details
.defaults ⇒ Object
8 9 10 |
# File 'lib/heroics/configuration.rb', line 8 def self.defaults @defaults ||= Configuration.new end |
Instance Method Details
#headers=(headers) ⇒ Object
40 41 42 43 |
# File 'lib/heroics/configuration.rb', line 40 def headers=(headers) raise "Must provide a hash of headers" unless headers.is_a?(Hash) [:default_headers] = headers end |
#schema_filepath=(schema_filepath) ⇒ Object
24 25 26 |
# File 'lib/heroics/configuration.rb', line 24 def schema_filepath=(schema_filepath) @schema = Heroics::Schema.new(MultiJson.decode(open(schema_filepath).read)) end |