Sha256: 9695f3e8d771b60ff08fc385b38d4f662c477bce679c5a173179725fa8cd3528

Contents?: true

Size: 786 Bytes

Versions: 2

Compression:

Stored size: 786 Bytes

Contents

module Alf
  module Iterator
    class Proxy
      include Iterator

      # @return [Symbol] name of the dataset to request to environment
      attr_reader :dataset

      #
      # Creates a proxy instance.
      #
      # @param [Environment] env the environment serving iterator instances
      # @param [Symbol] dataset named dataset to rely on
      #
      def initialize(env, dataset)
        @environment, @dataset = env, dataset
      end

      # (see Iterator#pipe)
      def pipe(input, environment = nil)
        @environment ||= environment 
        @dataset ||= input
        self
      end

      # (see Iterator#each)
      def each(&block)
        @environment.dataset(@dataset).each(&block)
      end

    end # class Proxy
  end # module Iterator
end # module Alf

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alf-0.10.1 lib/alf/iterator/proxy.rb
alf-0.10.0 lib/alf/iterator/proxy.rb