Class: Sorted::SQLQuery
- Inherits:
-
Object
- Object
- Sorted::SQLQuery
- Extended by:
- Parse
- Defined in:
- lib/sorted/sql_query.rb
Constant Summary collapse
- REGEXP =
/(([a-z0-9._]+)\s([asc|desc]+)|[a-z0-9._]+)/i
Class Method Summary collapse
Methods included from Parse
Class Method Details
.encode(set, quote_proc = ->(f) { f }) ⇒ Object
18 19 20 |
# File 'lib/sorted/sql_query.rb', line 18 def self.encode(set, quote_proc = ->(f) { f }) set.map { |a| "#{column(a[0], quote_proc)} #{a[1].upcase}" }.join(', ') end |
.parse(raw) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/sorted/sql_query.rb', line 10 def self.parse(raw) split(raw, /,/) do |set, part| m = part.match(REGEXP) next unless m set << parse_match(m) end end |