Sha256: c879d56510259fd1e94b7976478468defcff795a5d1b7e39bc522fb087b5b0d6

Contents?: true

Size: 876 Bytes

Versions: 1

Compression:

Stored size: 876 Bytes

Contents

module Alf
  module Engine
    class Ungroup
      include Cog

      # @return [Enumerable] The operand
      attr_reader :operand

      # @return [AttrName] Relation-valued attribute to ungroup
      attr_reader :attribute

      # Creates a Ungroup instance
      def initialize(operand, attribute, expr = nil, compiler = nil)
        super(expr, compiler)
        @operand = operand
        @attribute = attribute
      end

      # (see Cog#each)
      def _each
        operand.each do |tuple|
          tuple = tuple.dup
          tuple = tuple.to_hash unless tuple.is_a?(Hash)
          tuple.delete(@attribute).each do |subtuple|
            subtuple = symbolize(subtuple)
            yield tuple.merge(subtuple)
          end
        end
      end

      def arguments
        [ attribute ]
      end

    end # class Ungroup
  end # module Engine
end # module Alf

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alf-core-0.15.0 lib/alf/engine/ungroup.rb