Class: DataMapper::Query::Sort
- Inherits:
-
Object
- Object
- DataMapper::Query::Sort
- Defined in:
- lib/dm-core/query/sort.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
TODO: document.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
private
TODO: document.
-
#direction ⇒ Object
TODO: document.
Instance Attribute Details
#value ⇒ Object (readonly)
TODO: document
8 9 10 |
# File 'lib/dm-core/query/sort.rb', line 8 def value @value end |
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.
TODO: document
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/dm-core/query/sort.rb', line 18 def <=>(other) other_value = other.value cmp = case when @value.nil? && other_value.nil? 0 when @value.nil? 1 when other_value.nil? -1 else @value <=> other_value end @ascending ? cmp : cmp * -1 end |
#direction ⇒ Object
TODO: document
12 13 14 |
# File 'lib/dm-core/query/sort.rb', line 12 def direction @ascending ? :ascending : :descending end |