cw_sort_order 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/cw_sort_order.rb CHANGED
@@ -344,5 +344,16 @@ class SortOrder
344
344
  @ordering.concat(o.ordering)
345
345
  self
346
346
  end
347
+
348
+ # To String
349
+ #
350
+ # Converts a Sort Order to a SQL string
351
+ #
352
+ # Returns:
353
+ # (String) version of the order as you would specify to a SQL query
354
+ def to_s
355
+ self.collect{|col,dir| "'#{col}' #{dir}"}.join(',')
356
+ end
357
+
347
358
  end # SortOrder
348
359
  end # CW
@@ -105,4 +105,9 @@ class PaginationOrderTest < Test::Unit::TestCase
105
105
  assert_nil a.shift
106
106
  end
107
107
 
108
+ def test_to_s
109
+ a = CW::SortOrder.new + '1' - '2' - '3' + '4'
110
+ assert_equal "'1' asc,'2' desc,'3' desc,'4' asc", a.to_s
111
+ end
112
+
108
113
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cw_sort_order
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 2
10
- version: 1.0.2
9
+ - 3
10
+ version: 1.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Christopher Wojno