Class: LinodeAPI::Raw

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

Overview

Raw API object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Raw



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

def initialize(params = {})
  self.class.base_uri params.fetch(:endpoint, DEFAULT_ENDPOINT)
  @names = params.fetch(:names) { [] }
  @spec = params.fetch(:spec) { LinodeAPI.spec }
  @apikey = params.fetch(:apikey) { authenticate(params).first }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



40
41
42
43
44
45
46
# File 'lib/linodeapi/raw.rb', line 40

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 Attribute Details

#apikeyObject (readonly)

Returns the value of attribute apikey.



12
13
14
# File 'lib/linodeapi/raw.rb', line 12

def apikey
  @apikey
end

#namesObject (readonly)

Returns the value of attribute names.



12
13
14
# File 'lib/linodeapi/raw.rb', line 12

def names
  @names
end

#specObject (readonly)

Returns the value of attribute spec.



12
13
14
# File 'lib/linodeapi/raw.rb', line 12

def spec
  @spec
end

Instance Method Details

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



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

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

#to_sObject Also known as: inspect



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

def to_s
  'LinodeAPI::Raw object'
end