Class: Hubspot::Collection
- Inherits:
-
Object
- Object
- Hubspot::Collection
show all
- Defined in:
- lib/hubspot/collection.rb
Instance Method Summary
collapse
Constructor Details
#initialize(opts = {}, &block) ⇒ Collection
Returns a new instance of Collection.
2
3
4
5
6
|
# File 'lib/hubspot/collection.rb', line 2
def initialize(opts = {}, &block)
@options = opts
@fetch_proc = block
fetch
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
38
39
40
|
# File 'lib/hubspot/collection.rb', line 38
def method_missing(method, *args, &block)
@resources.public_send(method, *args, &block)
end
|
Instance Method Details
#refresh ⇒ Object
8
9
10
11
|
# File 'lib/hubspot/collection.rb', line 8
def refresh
fetch
self
end
|
#resources ⇒ Object
13
14
15
|
# File 'lib/hubspot/collection.rb', line 13
def resources
@resources
end
|
#update_all(opts = {}) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/hubspot/collection.rb', line 17
def update_all(opts = {})
return true if empty?
resource_class = resources.first.class
unless resource_class.respond_to?(:batch_update)
raise "#{resource_class} does not support bulk update"
end
resource_class.batch_update(resources, opts)
end
|