Class: APIHub::Company

Inherits:
Base show all
Defined in:
lib/apihub/company.rb

Direct Known Subclasses

Streaming::Company

Class Method Summary collapse

Methods inherited from Resource

delete, endpoint, get, options, path, post, put, request, uri, url

Methods inherited from Mash

#custom_reader, #custom_writer, #deep_merge, #deep_update, #delete, #dup, #fetch, #id, #initialize, #initializing_reader, #key?, #method_missing, new, #regular_dup, #replace, #respond_to?, #shallow_merge, #shallow_update, #type, #underbang_reader

Constructor Details

This class inherits a constructor from APIHub::Mash

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class APIHub::Mash

Class Method Details

.find(values, options = {}) ⇒ Object Also known as: []



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/apihub/company.rb', line 6

def self.find(values, options = {})
  unless values.is_a?(Hash)
    values = {:id => values}
  end

  options = options.dup
  params  = options.delete(:params) || {}

  if domain = values[:domain]
    response = get(uri(:domain, domain), params, options)

  elsif id = values[:id]
    response = get(id, params, options)

  else
    raise ArgumentError, 'Invalid values'
  end

  if response.status == 202
    self.new(pending: true)
  else
    self.new(response)
  end

rescue Nestful::ResourceNotFound
end