Sha256: b1438030667906eaffd5791997033c19c42e885bf584b4d0706d4506b7e070e1

Contents?: true

Size: 876 Bytes

Versions: 5

Compression:

Stored size: 876 Bytes

Contents

module Alf
  module Engine
    #
    # Renames tuples from the operand according to a Renaming info.
    # 
    # Example:
    #
    #     rel = [
    #       {:name => "Jones", :city => "London"}
    #     ]
    #     Rename.new(rel, Renaming[:name => :last_name]).to_a
    #     # => [
    #     #      {:last_name => "Jones", :city => "London"}
    #     #    ]
    #
    class Rename < Cog

      # @return [Enumerable] The operand
      attr_reader :operand

      # @return [Renaming] Renaming info
      attr_reader :renaming

      # Creates a Rename instance
      def initialize(operand, renaming)
        @operand = operand
        @renaming = renaming
      end

      # (see Cog#each)
      def each
        operand.each do |tuple|
          yield @renaming.rename_tuple(tuple)
        end
      end

    end # class Rename
  end # module Engine
end # module Alf

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-0.12.2 lib/alf-engine/alf/engine/rename.rb
alf-0.12.1 lib/alf-engine/alf/engine/rename.rb
alf-0.12.0 lib/alf-engine/alf/engine/rename.rb
alf-0.11.1 lib/alf-engine/alf/engine/rename.rb
alf-0.11.0 lib/alf-engine/alf/engine/rename.rb