Sha256: 3bb5d78590d7e6774efdfffc9ffbf3a07fe1c0cf9d3ed92f3e139f49c0af962e

Contents?: true

Size: 603 Bytes

Versions: 4

Compression:

Stored size: 603 Bytes

Contents

module Piglet
  module Relation
    class Cross # :nodoc:
      include Relation
    
      def initialize(relations, options={})
        options ||= {}
        @sources, @parallel = relations, options[:parallel]
      end
    
      def schema
        schemas = @sources.map { |s| s.schema }
        schemas.first.union(schemas[1..-1])
      end
    
      def to_s
        str  = "CROSS #{source_aliases.join(', ')}"
        str << " PARALLEL #{@parallel}" if @parallel
        str
      end
  
    private
    
      def source_aliases
        @sources.map { |s| s.alias }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
piglet-0.2.4 lib/piglet/relation/cross.rb
piglet-0.2.3 lib/piglet/relation/cross.rb
piglet-0.2.2 lib/piglet/relation/cross.rb
piglet-0.2.0 lib/piglet/relation/cross.rb