Sha256: 965427cca5189ac94ff2aca4ecddda26ce3576beb92e173a6f1267ab73fab5bf

Contents?: true

Size: 795 Bytes

Versions: 4

Compression:

Stored size: 795 Bytes

Contents

# frozen_string_literal: true

module Leftovers
  module ProcessorBuilders
    module TransformChain
      class << self
        def build(transforms, next_transform)
          case transforms
          when ::Hash then build_from_hash(transforms, next_transform)
          when ::Symbol then Transform.build(transforms, true, next_transform)
          # :nocov:
          else raise UnexpectedCase, "Unhandled value #{transforms.inspect}"
            # :nocov:
          end
        end

        private

        def build_from_hash(transforms, next_transform)
          transforms.reverse_each do |(transform, transform_arg)|
            next_transform = Transform.build(transform, transform_arg, next_transform)
          end

          next_transform
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
leftovers-0.12.2 lib/leftovers/processor_builders/transform_chain.rb
leftovers-0.12.1 lib/leftovers/processor_builders/transform_chain.rb
leftovers-0.12.0 lib/leftovers/processor_builders/transform_chain.rb
leftovers-0.11.2 lib/leftovers/processor_builders/transform_chain.rb