Module: Reshape::Configuration

Included in:
Reshape, Client
Defined in:
lib/reshape/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
[
:adapter,
:api_version,
:api_endpoint,
:web_endpoint,
:proxy,
:consumer_token,
:consumer_secret,
:consumer_options,
:oauth_token,
:oauth_secret,
:response_format,
:user_agent].freeze
DEFAULT_ADAPTER =
Faraday.default_adapter
DEFAULT_API_VERSION =
'v1'
DEFAULT_API_ENDPOINT =
'http://api.shapeways.com/'
DEFAULT_WEB_ENDPOINT =
'http://www.shapeways.com/'
DEFAULT_USER_AGENT =
"Reshape Rubygem #{Reshape::VERSION}".freeze
DEFAULT_RESPONSE_FORMAT =
'json'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



29
30
31
# File 'lib/reshape/configuration.rb', line 29

def self.extended(base)
  base.reset
end

Instance Method Details

#api_endpoint=(value) ⇒ Object



41
42
43
# File 'lib/reshape/configuration.rb', line 41

def api_endpoint=(value)
  @api_endpoint = File.join(value, "")
end

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

Yields:

  • (_self)

Yield Parameters:



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

def configure
  yield self
end

#optionsObject



37
38
39
# File 'lib/reshape/configuration.rb', line 37

def options
  VALID_OPTIONS_KEYS.inject({}){|o,k| o.merge!(k => send(k)) }
end

#resetObject



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/reshape/configuration.rb', line 49

def reset
  self.adapter = DEFAULT_ADAPTER
  self.api_version = DEFAULT_API_VERSION
  self.api_endpoint = DEFAULT_API_ENDPOINT
  self.web_endpoint = DEFAULT_WEB_ENDPOINT
  self.proxy = nil
  self.consumer_token = nil
  self.consumer_secret = nil
  self.oauth_token = nil
  self.oauth_secret = nil
  self.response_format = DEFAULT_RESPONSE_FORMAT
  self.user_agent = DEFAULT_USER_AGENT
end

#web_endpoint=(value) ⇒ Object



45
46
47
# File 'lib/reshape/configuration.rb', line 45

def web_endpoint=(value)
  @web_endpoint = File.join(value, "")
end