Module: Zenaton::Traits::Zenatonable

Extended by:
ActiveSupport::Concern
Included in:
Zenaton::Tasks::Wait, Workflows::Version
Defined in:
lib/zenaton/traits/zenatonable.rb

Overview

Module to be included in tasks and workflows

Instance Method Summary collapse

Instance Method Details

#dispatchObject

Sends self as the single job to be dispatched to the engine and returns the result



21
22
23
# File 'lib/zenaton/traits/zenatonable.rb', line 21

def dispatch
  Engine.instance.dispatch([self])
end

#executeObject

Sends self as the single job to be executed to the engine and returns the result



15
16
17
# File 'lib/zenaton/traits/zenatonable.rb', line 15

def execute
  Engine.instance.execute([self])[0]
end

#schedule(cron) ⇒ Object

Sets the repeatable frequency of execution of a given job



26
27
28
29
30
31
32
33
# File 'lib/zenaton/traits/zenatonable.rb', line 26

def schedule(cron)
  if !cron.is_a?(String) || cron.blank?
    raise InvalidArgumentError,
          "The cron passed to 'schedule' must be a non empty string"
  end

  Engine.instance.schedule([self], cron)
end