Method: Waxx::View#parse_col
- Defined in:
- lib/waxx/view.rb
#parse_col(str) ⇒ Object
Parse a column (internal method used by col)
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/waxx/view.rb', line 198 def parse_col(str) nam = rel = col = nil parts = str.split(/[:\.]/) case str # alias:relationship.column when /^\w+:\s*\w+\.\w+$/ nam, rel, col = str.split(/[:\.]/).map{|part| part.strip} # relationship.column when /^\w+\.\w+$/ rel, col = str.split(".") # alias:column (from primary object/table) when /^\w+:\w+$/ nam, col = str.split(":") # column (from primary object/table) when /^\w+$/ col = str else raise "Could not parse column definition in Waxx::View.parse_col (#{name}). Unknown match: #{str}." end nam = col if nam.nil? rel = @table if rel.nil? [nam, rel, col] end |