class Heroics::Configuration

Attempts to load configuration, provides defaults, and provide helpers to access that data

Attributes

base_url[R]
cache_path[R]
module_name[R]
options[R]
ruby_name_replacement_patterns[R]
schema[R]

Public Class Methods

defaults() click to toggle source
# File lib/heroics/configuration.rb, line 19
def self.defaults
  @defaults ||= Configuration.new
end
new() { |self| ... } click to toggle source
# 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
restore_defaults() click to toggle source
# File lib/heroics/configuration.rb, line 23
def self.restore_defaults
  @defaults = Configuration.new
end

Public Instance Methods

acceptable_status_codes=(status_codes) click to toggle source
# File lib/heroics/configuration.rb, line 72
def acceptable_status_codes=(status_codes)
  @options[:status_codes] = status_codes
end
base_url=(base_url) click to toggle source
# File lib/heroics/configuration.rb, line 50
def base_url=(base_url)
  @base_url = base_url
end
cache_path=(cache_path) click to toggle source
# File lib/heroics/configuration.rb, line 54
def cache_path=(cache_path)
  @options[:cache] = "Moneta.new(:File, dir: \"#{cache_path}\")"
end
headers=(headers) click to toggle source
# 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
module_name=(module_name) click to toggle source
# File lib/heroics/configuration.rb, line 46
def module_name=(module_name)
  @module_name = module_name
end
rate_throttle=(rate_throttle) click to toggle source
# File lib/heroics/configuration.rb, line 68
def rate_throttle=(rate_throttle)
  @options[:rate_throttle] = rate_throttle
end
ruby_name_replacement_patterns=(patterns) click to toggle source
# File lib/heroics/configuration.rb, line 63
def ruby_name_replacement_patterns=(patterns)
  raise "Must provide a hash of replacements" unless patterns.is_a?(Hash)
  @ruby_name_replacement_patterns = patterns
end
schema=(schema) click to toggle source
# File lib/heroics/configuration.rb, line 38
def schema=(schema)
  @schema = schema
end
schema_filepath=(schema_filepath) click to toggle source
# File lib/heroics/configuration.rb, line 42
def schema_filepath=(schema_filepath)
  @schema = Heroics::Schema.new(MultiJson.decode(open(schema_filepath).read))
end