Module: JobWorkflow::DSL
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActiveJob::Continuable
- Defined in:
- lib/job_workflow/dsl.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#_context ⇒ Object
: () -> Context?.
-
#_context=(context) ⇒ Object
: (Context) -> void.
-
#deserialize(job_data) ⇒ Object
: (Hash[String, untyped]) -> void.
-
#output ⇒ Object
: () -> Output.
-
#perform(arguments) ⇒ Object
: (Hash[untyped, untyped]) -> void.
-
#serialize ⇒ Object
: () -> Hash[String, untyped].
Instance Method Details
#_context ⇒ Object
: () -> Context?
54 55 56 |
# File 'lib/job_workflow/dsl.rb', line 54 def _context @_context end |
#_context=(context) ⇒ Object
: (Context) -> void
49 50 51 |
# File 'lib/job_workflow/dsl.rb', line 49 def _context=(context) @_context = context end |
#deserialize(job_data) ⇒ Object
: (Hash[String, untyped]) -> void
64 65 66 67 68 69 70 71 72 |
# File 'lib/job_workflow/dsl.rb', line 64 def deserialize(job_data) super job_data["job_workflow_context"]&.then do |context_data| self._context = Context.deserialize( context_data.merge("job" => self, "workflow" => self.class._workflow) ) end end |
#output ⇒ Object
: () -> Output
41 42 43 44 45 46 |
# File 'lib/job_workflow/dsl.rb', line 41 def output context = self._context raise "context is not set." if context.nil? context.output end |
#perform(arguments) ⇒ Object
: (Hash[untyped, untyped]) -> void
34 35 36 37 38 |
# File 'lib/job_workflow/dsl.rb', line 34 def perform(arguments) self._context ||= Context.from_hash({ job: self, workflow: self.class._workflow }) context = self._context #: Context Runner.new(context: context._update_arguments(arguments)).run end |
#serialize ⇒ Object
: () -> Hash[String, untyped]
59 60 61 |
# File 'lib/job_workflow/dsl.rb', line 59 def serialize super.merge({ "job_workflow_context" => _context&.serialize }.compact) end |