Class: Crunchbase::Organization
- Inherits:
-
Object
- Object
- Crunchbase::Organization
show all
- Defined in:
- lib/crunchbase/organization.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(data, meta) ⇒ Organization
Returns a new instance of Organization.
10
11
12
13
|
# File 'lib/crunchbase/organization.rb', line 10
def initialize(data, meta)
@mash = data
self.metadata = meta
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *arguments, &block) ⇒ Object
15
16
17
|
# File 'lib/crunchbase/organization.rb', line 15
def method_missing(method_sym, *arguments, &block)
@mash.send(method_sym, *arguments)
end
|
Instance Attribute Details
Returns the value of attribute metadata.
8
9
10
|
# File 'lib/crunchbase/organization.rb', line 8
def metadata
@metadata
end
|
Class Method Details
.all(options = {}) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/crunchbase/organization.rb', line 27
def self.all(options = {})
opts = options.merge({user_key: Crunchbase.config.user_key})
response = Faraday.get("#{Crunchbase.config.host}/#{Crunchbase.config.api_version_prefix}/organizations", opts)
raise "Error" if response.status != 200
raw = Hashie::Mash.new(JSON.parse(response.body))
collection = raw.data.items
collection.map { |item| new(item, raw.metadata) }
rescue => e
[]
end
|
.find(permalink) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/crunchbase/organization.rb', line 41
def self.find(permalink)
response = Faraday.get("#{Crunchbase.config.host}/#{Crunchbase.config.api_version_prefix}/organization/#{permalink}", user_key: Crunchbase.config.user_key)
raise "Error" if response.status != 200
raw = Hashie::Mash.new(JSON.parse(response.body))
new(raw.data, raw.metadata)
rescue
nil
end
|
Instance Method Details
#load_details ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/crunchbase/organization.rb', line 19
def load_details
if properties
return self
else
Organization.find(path.sub("organization/", ''))
end
end
|