Sha256: 473b791d56891b028d0cf015837158b59bc7f80dbf76cb8006b82e412f7297a3

Contents?: true

Size: 722 Bytes

Versions: 1

Compression:

Stored size: 722 Bytes

Contents

#
#  Copyright (c) 2011, SoundCloud Ltd., Rany Keddo, Tobias Bielohlawek, Tobias
#  Schmidt
#
#  Determine and format columns common to origin and destination.
#

module Lhm
  class Intersection
    def initialize(origin, destination)
      @origin = origin
      @destination = destination
    end

    def common
      @origin.columns.keys & @destination.columns.keys
    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

1 entries across 1 versions & 1 rubygems

Version Path
lhm-1.0.0.rc.1 lib/lhm/intersection.rb