Class: LinodeAPI::Raw

Inherits:
Object
  • Object
show all
Extended by:
Helpers
Includes:
HTTParty
Defined in:
lib/linodeapi/raw.rb

Overview

Raw API object

Direct Known Subclasses

Retryable

Instance Method Summary collapse

Methods included from Helpers

clean, create_http_error, error_check, parse, validate

Constructor Details

#initialize(params = {}) ⇒ Raw

Returns a new instance of Raw.



13
14
15
16
17
18
19
20
# File 'lib/linodeapi/raw.rb', line 13

def initialize(params = {})
  @options = params
  @options[:endpoint] ||= DEFAULT_ENDPOINT
  @options[:names] ||= []
  @options[:spec] ||= LinodeAPI.spec
  @options[:apikey] ||= authenticate(params)
  @options[:user_agent_prefix] ||= ''
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)



57
58
59
60
61
62
63
# File 'lib/linodeapi/raw.rb', line 57

def method_missing(method, *args, &block)
  return super unless respond_to? method
  case spec[:subs][method][:type]
  when :group then make_group method
  when :call then make_call method, *args
  end
end

Instance Method Details

#apikeyObject



39
40
41
# File 'lib/linodeapi/raw.rb', line 39

def apikey
  @apikey ||= @options[:apikey]
end

#endpointObject



43
44
45
# File 'lib/linodeapi/raw.rb', line 43

def endpoint
  @endpoint ||= @options[:endpoint]
end

#namesObject



31
32
33
# File 'lib/linodeapi/raw.rb', line 31

def names
  @names ||= @options[:names]
end

#respond_to_missing?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/linodeapi/raw.rb', line 22

def respond_to_missing?(method, include_private = false)
  spec[:subs].include?(method) || super
end

#specObject



35
36
37
# File 'lib/linodeapi/raw.rb', line 35

def spec
  @spec ||= @options[:spec]
end

#to_sObject Also known as: inspect



26
27
28
# File 'lib/linodeapi/raw.rb', line 26

def to_s
  'LinodeAPI::Raw object'
end