Sha256: 20f14e6fba47bcd26deef4f8812f3e584ea8ba192811bc34fe4398a1d0f5cc4f

Contents?: true

Size: 966 Bytes

Versions: 1

Compression:

Stored size: 966 Bytes

Contents

# frozen_string_literal: true

module Floe
  class Workflow
    class Context
      def initialize(context = nil, input: {})
        context = JSON.parse(context) if context.kind_of?(String)

        @context = context || {
          "Execution"    => {
            "Input" => input
          },
          "State"        => {},
          "States"       => [],
          "StateMachine" => {},
          "Task"         => {}
        }
      end

      def execution
        @context["Execution"]
      end

      def state
        @context["State"]
      end

      def states
        @context["States"]
      end

      def state_machine
        @context["StateMachine"]
      end

      def task
        @context["Task"]
      end

      def [](key)
        @context[key]
      end

      def []=(key, val)
        @context[key] = val
      end

      def dig(*args)
        @context.dig(*args)
      end

      def to_h
        @context
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
floe-0.2.0 lib/floe/workflow/context.rb