Sha256: 06943260db32c2dbedec1ed1749489706b7f1ae8024bec1e26d704f1110af325

Contents?: true

Size: 798 Bytes

Versions: 6

Compression:

Stored size: 798 Bytes

Contents

require "parslet"

module Floe
  class Workflow
    class IntrinsicFunction
      def self.value(payload, context = {}, input = {})
        new(payload).value(context, input)
      end

      def self.intrinsic_function?(payload)
        payload.start_with?("States.")
      end

      attr_reader :payload

      def initialize(payload)
        @payload = payload
        @tree    = Parser.new.parse(payload)

        Floe.logger.debug { "Parsed intrinsic function: #{payload.inspect} => #{tree.inspect}" }
      rescue Parslet::ParseFailed => err
        raise Floe::InvalidWorkflowError, err.message
      end

      def value(context = {}, input = {})
        Transformer.new.apply(tree, :context => context, :input => input)
      end

      private

      attr_reader :tree
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
floe-0.15.1 lib/floe/workflow/intrinsic_function.rb
floe-0.15.0 lib/floe/workflow/intrinsic_function.rb
floe-0.14.0 lib/floe/workflow/intrinsic_function.rb
floe-0.13.1 lib/floe/workflow/intrinsic_function.rb
floe-0.13.0 lib/floe/workflow/intrinsic_function.rb
floe-0.12.0 lib/floe/workflow/intrinsic_function.rb