Class: BaseCradle::TimelineTasks
- Inherits:
-
Object
- Object
- BaseCradle::TimelineTasks
- Includes:
- Enumerable
- Defined in:
- lib/basecradle/items.rb
Overview
One timeline’s tasks: create here, or iterate (newest first).
Instance Method Summary collapse
-
#create(instructions:, activate_at:) ⇒ Object
Schedule a task on this timeline.
- #each(&block) ⇒ Object
-
#initialize(client, timeline_uuid) ⇒ TimelineTasks
constructor
A new instance of TimelineTasks.
Constructor Details
#initialize(client, timeline_uuid) ⇒ TimelineTasks
Returns a new instance of TimelineTasks.
203 204 205 206 |
# File 'lib/basecradle/items.rb', line 203 def initialize(client, timeline_uuid) @client = client @timeline_uuid = timeline_uuid end |
Instance Method Details
#create(instructions:, activate_at:) ⇒ Object
Schedule a task on this timeline. activate_at accepts a Time/DateTime (serialized to ISO 8601 — make it timezone-aware to be unambiguous) or an ISO 8601 string.
210 211 212 213 214 215 216 217 |
# File 'lib/basecradle/items.rb', line 210 def create(instructions:, activate_at:) activate_at = activate_at.iso8601 if activate_at.respond_to?(:iso8601) response = @client.request( "POST", "/timelines/#{@timeline_uuid}/tasks", json: { "task" => { "instructions" => instructions, "activate_at" => activate_at } } ) Task.new(response.fetch("task"), client: @client) end |
#each(&block) ⇒ Object
219 220 221 |
# File 'lib/basecradle/items.rb', line 219 def each(&block) TasksResource.new(@client).filter(timeline: @timeline_uuid).each(&block) end |