JasonKing-good_sort 0.1.10 → 0.2.0

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.
Files changed (3) hide show
  1. data/VERSION.yml +2 -2
  2. data/lib/good_sort/sorter.rb +9 -3
  3. metadata +1 -1
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :minor: 1
3
- :patch: 10
2
+ :minor: 2
3
+ :patch: 0
4
4
  :major: 0
@@ -28,10 +28,16 @@ module GoodSort
28
28
  if f.is_a? Hash
29
29
  f.each do |k,v|
30
30
  ass = association_for( k )
31
- unless ass_has_attr( ass, v )
32
- raise ArgumentError, "belongs_to association #{k} does not have specified column #{v}"
31
+ if v.is_a? String
32
+ # if we're supplied a string, then assume they know what they're
33
+ # doing and just string it up
34
+ sort_fields[k.to_sym] = { :order => v, :joins => k.to_sym }
35
+ else
36
+ unless ass_has_attr( ass, v )
37
+ raise ArgumentError, "belongs_to association #{k} does not have specified column #{v}"
38
+ end
39
+ sort_fields[k.to_sym] = { :order => ass_to_table(ass) + '.' + v.to_s, :joins => k.to_sym }
33
40
  end
34
- sort_fields[k.to_sym] = { :order => ass_to_table(ass) + '.' + v.to_s, :joins => k.to_sym }
35
41
  end
36
42
  next
37
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: JasonKing-good_sort
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason King