Sha256: 52ebbcb33d3d2731ae6ee565f35e602e19d9fbd8bf2b72b6888ad6d2d2f3add7

Contents?: true

Size: 722 Bytes

Versions: 8

Compression:

Stored size: 722 Bytes

Contents

# Copyright (c) 2011, SoundCloud Ltd., Rany Keddo, Tobias Bielohlawek, Tobias
# Schmidt

module Lhm
  #  Determine and format columns common to origin and destination.
  class Intersection
    def initialize(origin, destination)
      @origin = origin
      @destination = destination
    end

    def common
      (@origin.columns.keys & @destination.columns.keys).sort
    end

    def escaped
      common.map { |name| tick(name)  }
    end

    def joined
      escaped.join(", ")
    end

    def typed(type)
      common.map { |name| qualified(name, type)  }.join(", ")
    end

  private

    def qualified(name, type)
      "#{ type }.`#{ name }`"
    end

    def tick(name)
      "`#{ name }`"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
lhm-1.1.0 lib/lhm/intersection.rb
lhm-1.0.3 lib/lhm/intersection.rb
lhm-1.0.2 lib/lhm/intersection.rb
lhm-1.0.0.rc7 lib/lhm/intersection.rb
lhm-1.0.0.rc6 lib/lhm/intersection.rb
lhm-1.0.0.rc5 lib/lhm/intersection.rb
lhm-1.0.0.rc4 lib/lhm/intersection.rb
lhm-1.0.0.rc3 lib/lhm/intersection.rb