Sha256: a43ac5a80f099c67db729abea507e2588ebf46418a8297d537735aa5b1ac54dd

Contents?: true

Size: 658 Bytes

Versions: 5

Compression:

Stored size: 658 Bytes

Contents

module Alf
  module Engine
    #
    # Unwraps a tuple attribute
    #
    class Unwrap < Cog

      # @return [Enumerable] The operand
      attr_reader :operand

      # @return [AttrName] Name of the attribute to unwrap
      attr_reader :attribute

      # Creates a SetAttr instance
      def initialize(operand, attribute)
        @operand = operand
        @attribute = attribute
      end

      # (see Cog#each)
      def each
        operand.each do |tuple|
          tuple = tuple.dup
          tuple.merge!(tuple.delete(@attribute) || {})
          yield tuple
        end
      end

    end # class Unwrap
  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/unwrap.rb
alf-0.12.1 lib/alf-engine/alf/engine/unwrap.rb
alf-0.12.0 lib/alf-engine/alf/engine/unwrap.rb
alf-0.11.1 lib/alf-engine/alf/engine/unwrap.rb
alf-0.11.0 lib/alf-engine/alf/engine/unwrap.rb