Sha256: d65d4c407c6d6fdfe9e616986211bd2341447bedeb2568ad43606ec632222aaa

Contents?: true

Size: 624 Bytes

Versions: 1

Compression:

Stored size: 624 Bytes

Contents

module MiniCamel
  module Processor
    class Each < Base

      values do
        attribute :field, Symbol
        attribute :in_field, Symbol
        attribute :additional_fields, [Symbol]
        attribute :with_class, Class
      end

      private

      def process(entry, additional_data)
        with_class.new(additional_data.merge(field => entry)).call
      end

      def fetch_additional_data(exchange)
        additional_fields.map{|f| {f => exchange.context_fetch(f)}}.reduce(&:merge) || {}
      end

      def fetch_collection(exchange)
        exchange.context_fetch(in_field)
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mini_camel-0.5.8 lib/mini_camel/processor/each.rb