Class: DataMapper::Query::Sort
Instance Attribute Summary collapse
- #value ⇒ Object readonly
Instance Method Summary collapse
Instance Attribute Details
Instance Method Details
#<=>(other) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/dm-core/query/sort.rb', line 15 def <=>(other) other_value = other.value value_nil = @value.nil? other_nil = other_value.nil? cmp = case when value_nil then other_nil ? 0 : 1 when other_nil then -1 else @value <=> other_value end @ascending ? cmp : cmp * -1 end |
#direction ⇒ Object
10 11 12 |
# File 'lib/dm-core/query/sort.rb', line 10 def direction @ascending ? :ascending : :descending end |