Class: Lhm::Intersection
- Inherits:
-
Object
- Object
- Lhm::Intersection
- Defined in:
- lib/lhm/intersection.rb
Overview
Determine and format columns common to origin and destination.
Instance Method Summary collapse
- #combined_joined ⇒ Object
- #combined_typed(type) ⇒ Object
- #common ⇒ Object
- #escaped ⇒ Object
- #escaped_insert ⇒ Object
-
#initialize(origin, destination, insert_trigger_additions) ⇒ Intersection
constructor
A new instance of Intersection.
- #insert ⇒ Object
- #joined ⇒ Object
- #typed(type) ⇒ Object
- #typed_unjoined(type) ⇒ Object
Constructor Details
#initialize(origin, destination, insert_trigger_additions) ⇒ Intersection
Returns a new instance of Intersection.
7 8 9 10 11 |
# File 'lib/lhm/intersection.rb', line 7 def initialize(origin, destination, insert_trigger_additions) @origin = origin @destination = destination @insert_trigger_additions = insert_trigger_additions end |
Instance Method Details
#combined_joined ⇒ Object
25 26 27 |
# File 'lib/lhm/intersection.rb', line 25 def combined_joined (escaped + escaped_insert).join(", ") end |
#combined_typed(type) ⇒ Object
29 30 31 |
# File 'lib/lhm/intersection.rb', line 29 def combined_typed(type) (common.map { |name| qualified(name, type) } + @insert_trigger_additions.values.map { |name| parenthesize(name) }).join(", ") end |
#common ⇒ Object
13 14 15 |
# File 'lib/lhm/intersection.rb', line 13 def common (@origin.columns.keys & @destination.columns.keys).sort end |
#escaped ⇒ Object
33 34 35 |
# File 'lib/lhm/intersection.rb', line 33 def escaped common.map { |name| tick(name) } end |
#escaped_insert ⇒ Object
21 22 23 |
# File 'lib/lhm/intersection.rb', line 21 def escaped_insert insert.map { |name| tick(name) } end |
#insert ⇒ Object
17 18 19 |
# File 'lib/lhm/intersection.rb', line 17 def insert @insert_trigger_additions.keys end |
#joined ⇒ Object
37 38 39 |
# File 'lib/lhm/intersection.rb', line 37 def joined escaped.join(", ") end |
#typed(type) ⇒ Object
45 46 47 |
# File 'lib/lhm/intersection.rb', line 45 def typed(type) common.map { |name| qualified(name, type) }.join(", ") end |
#typed_unjoined(type) ⇒ Object
41 42 43 |
# File 'lib/lhm/intersection.rb', line 41 def typed_unjoined(type) common.map { |name| qualified(name, type) } end |