Class: Serially::InstanceBase

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/serially/instance_base.rb

Instance Method Summary collapse

Constructor Details

#initialize(instance) ⇒ InstanceBase

Returns a new instance of InstanceBase.



5
6
7
8
# File 'lib/serially/instance_base.rb', line 5

def initialize(instance)
  @instance = instance
  @task_manager = Serially::TaskManager[instance.class]
end

Instance Method Details

#start!Object



13
14
15
# File 'lib/serially/instance_base.rb', line 13

def start!
  Serially::Job.enqueue(@instance.class, @instance.instance_id, @task_manager.queue)
end

#task_runsObject

Raises:



17
18
19
20
# File 'lib/serially/instance_base.rb', line 17

def task_runs
  raise NotSupportedError.new('Serially: task_runs query is supported only for ActiveRecord classes') unless @instance.class.is_active_record?
  Serially::TaskRun.where(item_class: @instance.class.to_s, item_id: @instance.id).order('task_order ASC')
end