Sha256: 31d099c78819ca338db87cfec7b7aacf088c55d626302ca724c6ee77c1849f87

Contents?: true

Size: 635 Bytes

Versions: 11

Compression:

Stored size: 635 Bytes

Contents

# frozen_string_literal: true

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

      def initialize(payload)
        @payload = payload
      end

      def value(context, input = {})
        obj, path =
          if payload.start_with?("$$")
            [context, payload[1..]]
          else
            [input, payload]
          end

        results = JsonPath.on(obj, path)

        results.count < 2 ? results.first : results
      end

      private

      attr_reader :payload
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
floe-0.5.0 lib/floe/workflow/path.rb
floe-0.4.1 lib/floe/workflow/path.rb
floe-0.4.0 lib/floe/workflow/path.rb
floe-0.3.1 lib/floe/workflow/path.rb
floe-0.3.0 lib/floe/workflow/path.rb
floe-0.2.3 lib/floe/workflow/path.rb
floe-0.2.2 lib/floe/workflow/path.rb
floe-0.2.1 lib/floe/workflow/path.rb
floe-0.2.0 lib/floe/workflow/path.rb
floe-0.1.1 lib/floe/workflow/path.rb
floe-0.1.0 lib/floe/workflow/path.rb