class Actionable::MemoryStore::Action
Attributes
execution_time[RW]
id[RW]
job_class_name[RW]
payload[RW]
status[RW]
target[RW]
target_class_name[RW]
target_id[RW]
Public Class Methods
build(data)
click to toggle source
# File lib/actionable/memory_store/action.rb, line 17 def self.build(data) this = new(data) this.status = :new this end
create(data)
click to toggle source
# File lib/actionable/memory_store/action.rb, line 11 def self.create(data) this = new(data) this.status = :new this end
Public Instance Methods
cancel()
click to toggle source
# File lib/actionable/memory_store/action.rb, line 36 def cancel update_attributes(status: :canceled) end
Also aliased as: cancel!
enqueue()
click to toggle source
# File lib/actionable/memory_store/action.rb, line 31 def enqueue update_attributes(status: :enqueued) Resque.enqueue(job_class,id.to_s) end
reschedule_for(execution_time)
click to toggle source
# File lib/actionable/memory_store/action.rb, line 42 def reschedule_for(execution_time) update_attributes(execution_time: execution_time) end
save()
click to toggle source
# File lib/actionable/memory_store/action.rb, line 27 def save Actionable::MemoryStore.insert(for_save) end
Protected Instance Methods
get_target_from_definition()
click to toggle source
# File lib/actionable/memory_store/action.rb, line 53 def get_target_from_definition return nil unless target_class.present? && target_id.present? target_class.find(target_id) end
job_class()
click to toggle source
# File lib/actionable/memory_store/action.rb, line 58 def job_class job_class_name.constantize if job_class_name.present? end
set_target_definition()
click to toggle source
# File lib/actionable/memory_store/action.rb, line 48 def set_target_definition target_class = target.class.to_s target_id = target.id end
target_class()
click to toggle source
# File lib/actionable/memory_store/action.rb, line 62 def target_class target_class_name.constantize if target_class_name.present? end
update_attributes(hash)
click to toggle source
# File lib/actionable/memory_store/action.rb, line 66 def update_attributes(hash) hash.each_pair do |key,value| instance_variable_set(:"@#{key}",value) end end
Private Instance Methods
for_save()
click to toggle source
# File lib/actionable/memory_store/action.rb, line 74 def for_save if @target.present? && (@target_id.nil? || @target_class.nil?) set_target_definition end json = as_json json.delete(:target) json end