Sha256: d4ab3dfb26b065dd534941ff98be6642d7127245e699d04f532be1fd3f882015

Contents?: true

Size: 548 Bytes

Versions: 4

Compression:

Stored size: 548 Bytes

Contents

# frozen_string_literal: true

module Pipeable
  module Steps
    # Merges initialized attributes with step argument for use by a subsequent step.
    class Merge < Abstract
      def initialize as: :step, **keywords
        super(**keywords)
        @as = as
      end

      def call result
        result.fmap do |input|
          if input.is_a? Hash
            input.merge! base_keywords
          else
            {as => input}.merge!(base_keywords)
          end
        end
      end

      private

      attr_reader :as
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pipeable-0.4.0 lib/pipeable/steps/merge.rb
pipeable-0.3.0 lib/pipeable/steps/merge.rb
pipeable-0.2.0 lib/pipeable/steps/merge.rb
pipeable-0.1.0 lib/pipeable/steps/merge.rb