class ROM::FMP::Header
@private
Attributes
columns[R]
table[R]
Public Class Methods
new(columns, table)
click to toggle source
# File lib/rom/fmp/header.rb, line 11 def initialize(columns, table) @columns = columns @table = table end
Public Instance Methods
names()
click to toggle source
# File lib/rom/fmp/header.rb, line 28 def names columns.map { |col| :"#{col.to_s.split('___').last}" } end
prefix(col_prefix)
click to toggle source
# File lib/rom/fmp/header.rb, line 52 def prefix(col_prefix) rename(Hash[columns.map { |col| [col, :"#{col_prefix}_#{col}"] }]) end
project(*names)
click to toggle source
# File lib/rom/fmp/header.rb, line 32 def project(*names) self.class.new(columns.find_all { |col| names.include?(col) }, table) end
qualified()
click to toggle source
# File lib/rom/fmp/header.rb, line 36 def qualified self.class.new(columns.map { |col| :"#{table}__#{col}" }, table) end
rename(options)
click to toggle source
# File lib/rom/fmp/header.rb, line 40 def rename(options) self.class.new(columns.map { |col| new_name = options[col] if new_name :"#{col}___#{new_name}" else col end }, table) end
to_ary()
click to toggle source
# File lib/rom/fmp/header.rb, line 16 def to_ary columns end
Also aliased as: to_a
to_h()
click to toggle source
# File lib/rom/fmp/header.rb, line 21 def to_h columns.each_with_object({}) do |col, h| left, right = col.to_s.split('___') h[left.to_sym] = (right || left).to_sym end end