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.
-
#ruby_name_replacement_patterns ⇒ Object
Returns the value of attribute ruby_name_replacement_patterns.
-
#schema ⇒ Object
Returns the value of attribute schema.
Class Method Summary collapse
Instance Method Summary collapse
- #acceptable_status_codes=(status_codes) ⇒ Object
- #headers=(headers) ⇒ Object
-
#initialize {|_self| ... } ⇒ Configuration
constructor
A new instance of Configuration.
- #rate_throttle=(rate_throttle) ⇒ Object
- #schema_filepath=(schema_filepath) ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Configuration
Returns a new instance of Configuration.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/heroics/configuration.rb', line 27 def initialize @options = {} @options[:cache] = 'Moneta.new(:Memory)' @options[:default_headers] = {} @options[:rate_throttle] = NullRateLimit @options[:status_codes] = [] @ruby_name_replacement_patterns = { /[\s-]+/ => '_' } yield self if block_given? end |
Instance Attribute Details
#base_url ⇒ Object
Returns the value of attribute base_url.
12 13 14 |
# File 'lib/heroics/configuration.rb', line 12 def base_url @base_url end |
#cache_path ⇒ Object
Returns the value of attribute cache_path.
12 13 14 |
# File 'lib/heroics/configuration.rb', line 12 def cache_path @cache_path end |
#module_name ⇒ Object
Returns the value of attribute module_name.
12 13 14 |
# File 'lib/heroics/configuration.rb', line 12 def module_name @module_name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/heroics/configuration.rb', line 12 def @options end |
#ruby_name_replacement_patterns ⇒ Object
Returns the value of attribute ruby_name_replacement_patterns.
12 13 14 |
# File 'lib/heroics/configuration.rb', line 12 def ruby_name_replacement_patterns @ruby_name_replacement_patterns end |
#schema ⇒ Object
Returns the value of attribute schema.
12 13 14 |
# File 'lib/heroics/configuration.rb', line 12 def schema @schema end |
Class Method Details
.defaults ⇒ Object
19 20 21 |
# File 'lib/heroics/configuration.rb', line 19 def self.defaults @defaults ||= Configuration.new end |
.restore_defaults ⇒ Object
23 24 25 |
# File 'lib/heroics/configuration.rb', line 23 def self.restore_defaults @defaults = Configuration.new end |
Instance Method Details
#acceptable_status_codes=(status_codes) ⇒ Object
72 73 74 |
# File 'lib/heroics/configuration.rb', line 72 def acceptable_status_codes=(status_codes) @options[:status_codes] = status_codes end |
#headers=(headers) ⇒ Object
58 59 60 61 |
# File 'lib/heroics/configuration.rb', line 58 def headers=(headers) raise "Must provide a hash of headers" unless headers.is_a?(Hash) @options[:default_headers] = headers end |
#rate_throttle=(rate_throttle) ⇒ Object
68 69 70 |
# File 'lib/heroics/configuration.rb', line 68 def rate_throttle=(rate_throttle) @options[:rate_throttle] = rate_throttle end |