Class: Pastvu::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/pastvu/configuration.rb

Constant Summary collapse

VALID_OPTIONS =
%i[
  host
  path
  user_agent
  ensure_successful_responses
  check_params_type
  check_params_value
]
DEFAULT_VALUES =
{
  default_host: "pastvu.com",
  default_path: "/api2",
  default_user_agent: "Ruby PastVu Gem/#{VERSION}, #{RUBY_PLATFORM}, Ruby/#{RUBY_VERSION}",
  default_ensure_successful_responses: true,
  default_check_params_type: true,
  default_check_params_value: true
}

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



23
24
25
# File 'lib/pastvu/configuration.rb', line 23

def initialize
  reset!
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



33
34
35
36
# File 'lib/pastvu/configuration.rb', line 33

def configure
  yield self
  self
end

#reset!Object



27
28
29
30
31
# File 'lib/pastvu/configuration.rb', line 27

def reset!
  VALID_OPTIONS.each do |option|
    self.send(option.to_s.concat("=").to_sym, DEFAULT_VALUES["default_".concat(option.to_s).to_sym])
  end
end