Sha256: 50fb52241fe5afd233beb29f90a5b8a54d78ece1a2b1457b7de24a9c3a221115

Contents?: true

Size: 939 Bytes

Versions: 7

Compression:

Stored size: 939 Bytes

Contents

# frozen_string_literal: true

module Floe
  class Workflow
    class ChoiceRule
      class << self
        def true?(payload, context, input)
          build(payload).true?(context, input)
        end

        def build(payload)
          data_expression = (payload.keys & %w[And Not Or]).empty?
          if data_expression
            Floe::Workflow::ChoiceRule::Data.new(payload)
          else
            Floe::Workflow::ChoiceRule::Boolean.new(payload)
          end
        end
      end

      attr_reader :next, :payload, :variable

      def initialize(payload)
        @payload = payload

        @next     = payload["Next"]
        @variable = payload["Variable"]
      end

      def true?(*)
        raise NotImplementedError, "Must be implemented in a subclass"
      end

      private

      def variable_value(context, input)
        @variable_value ||= Path.value(variable, context, input)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
floe-0.3.0 lib/floe/workflow/choice_rule.rb
floe-0.2.3 lib/floe/workflow/choice_rule.rb
floe-0.2.2 lib/floe/workflow/choice_rule.rb
floe-0.2.1 lib/floe/workflow/choice_rule.rb
floe-0.2.0 lib/floe/workflow/choice_rule.rb
floe-0.1.1 lib/floe/workflow/choice_rule.rb
floe-0.1.0 lib/floe/workflow/choice_rule.rb