module Isomorfeus module Operation class DeferredTask < LucidObject::Base STATES = %w[ready running failed] # when the task is added to the queue its added as ready # when its running, its running # when it failes, it failed, the exception attribute is filled # when it was successful, its removed from the queue attribute :operation_class_name, class: String, required: true, validate_block: proc { |v| raise 'Invalid Operation class!' unless Isomorfeus.valid_operation_class_name?(v) } attribute :props attribute :user_class_name, class: String, default: 'Anonymous' attribute :user_key, class: String, default: 'anonymous' attribute :state, class: String, required: true, index: :yes, ensure: proc { |v| Isomorfeus::Operation::DeferredTask::STATES.include?(v) ? v : 'ready' } attribute :exception attribute :rtime def get_exception Marshal.load(exception) if exception end end end end