lib/rom/sql/header.rb in rom-sql-0.3.0 vs lib/rom/sql/header.rb in rom-sql-0.3.1
- old
+ new
@@ -1,8 +1,7 @@
module ROM
module SQL
-
# @private
class Header
include Charlatan.new(:columns)
include Equalizer.new(:columns, :table)
@@ -17,14 +16,14 @@
columns
end
alias_method :to_a, :to_ary
def to_h
- columns.each_with_object({}) { |col, h|
+ columns.each_with_object({}) do |col, h|
left, right = col.to_s.split('___')
h[left.to_sym] = (right || left).to_sym
- }
+ end
end
def names
map { |col| :"#{col.to_s.split('___').last}" }
end
@@ -36,24 +35,22 @@
def qualified
map { |col| :"#{table}__#{col}" }
end
def rename(options)
- map { |col|
+ map do |col|
new_name = options[col]
if new_name
:"#{col}___#{new_name}"
else
col
end
- }
+ end
end
def prefix(col_prefix)
rename(Hash[map { |col| [col, :"#{col_prefix}_#{col}"] }])
end
-
end
-
end
end