Module: CrunchApi

Defined in:
lib/crunch-api.rb,
lib/crunch-api/default.rb,
lib/crunch-api/version.rb,
lib/crunch-api/supplier.rb

Defined Under Namespace

Modules: Default Classes: Supplier

Constant Summary collapse

VERSION =
"0.0.2"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.consumer_key=(value) ⇒ Object (writeonly)

Sets the attribute consumer_key

Parameters:

  • value

    the value to set the attribute consumer_key to.



7
8
9
# File 'lib/crunch-api.rb', line 7

def consumer_key=(value)
  @consumer_key = value
end

.consumer_secret=(value) ⇒ Object (writeonly)

Sets the attribute consumer_secret

Parameters:

  • value

    the value to set the attribute consumer_secret to.



7
8
9
# File 'lib/crunch-api.rb', line 7

def consumer_secret=(value)
  @consumer_secret = value
end

.endpoint=(value) ⇒ Object (writeonly)

Sets the attribute endpoint

Parameters:

  • value

    the value to set the attribute endpoint to.



7
8
9
# File 'lib/crunch-api.rb', line 7

def endpoint=(value)
  @endpoint = value
end

.oauth_token=(value) ⇒ Object (writeonly)

Sets the attribute oauth_token

Parameters:

  • value

    the value to set the attribute oauth_token to.



7
8
9
# File 'lib/crunch-api.rb', line 7

def oauth_token=(value)
  @oauth_token = value
end

.oauth_token_secret=(value) ⇒ Object (writeonly)

Sets the attribute oauth_token_secret

Parameters:

  • value

    the value to set the attribute oauth_token_secret to.



7
8
9
# File 'lib/crunch-api.rb', line 7

def oauth_token_secret=(value)
  @oauth_token_secret = value
end

Class Method Details

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

Yields:

  • (_self)

Yield Parameters:

  • _self (CrunchApi)

    the object that the method was called on



19
20
21
22
# File 'lib/crunch-api.rb', line 19

def configure
  yield self
  self
end

.keysObject



9
10
11
12
13
14
15
16
17
# File 'lib/crunch-api.rb', line 9

def keys
  @keys ||= [
      :consumer_key,
      :consumer_secret,
      :oauth_token,
      :oauth_token_secret,
      :endpoint
  ]
end

.optionsObject



24
25
26
# File 'lib/crunch-api.rb', line 24

def options
  Hash[CrunchApi.keys.map { |key| [key, instance_variable_get(:"@#{key}")] }]
end

.reset!Object Also known as: setup



28
29
30
31
32
33
# File 'lib/crunch-api.rb', line 28

def reset!
  CrunchApi.keys.each do |key|
    instance_variable_set(:"@#{key}", CrunchApi::Default.options[key])
  end
  self
end