Class: Crowdkit::Client::Poll
- Includes:
- Enumerable
- Defined in:
- lib/crowdkit/client/poll.rb
Instance Attribute Summary
Attributes inherited from API
#auto_pagination, #client, #stored_params
Instance Method Summary collapse
- #any? ⇒ Boolean
- #delete(*args) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(options, &block) ⇒ Poll
constructor
A new instance of Poll.
- #method_missing(method_name, *args, &block) ⇒ Object
Methods inherited from API
#arguments, extract_class_name, #id_key, namespace, #set, #with
Methods included from API::RequestMethods
Constructor Details
#initialize(options, &block) ⇒ Poll
Returns a new instance of Poll.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/crowdkit/client/poll.rb', line 5 def initialize(, &block) super(, &block) arguments([], required: [:job_id]) prepare_sawyer get_units @units.data.each do |unit| def unit.delete do_delete("units/#{id}/queue") end end unless @units.data.empty? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
27 28 29 |
# File 'lib/crowdkit/client/poll.rb', line 27 def method_missing(method_name, *args, &block) @units.send(method_name, *args, &block) end |
Instance Method Details
#any? ⇒ Boolean
23 24 25 |
# File 'lib/crowdkit/client/poll.rb', line 23 def any? last_response.status != 304 end |
#delete(*args) ⇒ Object
31 32 33 34 |
# File 'lib/crowdkit/client/poll.rb', line 31 def delete(*args) arguments(args, required: [:job_id]) do_delete("jobs/#{job_id}/units/queue", {ids: @units.data.map(&:id)}) if any? end |
#each(&block) ⇒ Object
19 20 21 |
# File 'lib/crowdkit/client/poll.rb', line 19 def each(&block) @units.each(&block) end |