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.
4
5
6
7
8
|
# File 'lib/hubspot/collection.rb', line 4
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
40
41
42
|
# File 'lib/hubspot/collection.rb', line 40
def method_missing(method, *args, &block)
@resources.public_send(method, *args, &block)
end
|
Instance Method Details
#refresh ⇒ Object
10
11
12
13
|
# File 'lib/hubspot/collection.rb', line 10
def refresh
fetch
self
end
|
#resources ⇒ Object
15
16
17
|
# File 'lib/hubspot/collection.rb', line 15
def resources
@resources
end
|
#update_all(opts = {}) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/hubspot/collection.rb', line 19
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
|