Class: Tire::Search::Sort
- Inherits:
-
Object
- Object
- Tire::Search::Sort
- Defined in:
- lib/tire/search/sort.rb
Instance Method Summary collapse
- #by(name, direction = nil) ⇒ Object
-
#initialize(&block) ⇒ Sort
constructor
A new instance of Sort.
- #to_ary ⇒ Object
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize(&block) ⇒ Sort
Returns a new instance of Sort.
5 6 7 8 |
# File 'lib/tire/search/sort.rb', line 5 def initialize(&block) @value = [] block.arity < 1 ? self.instance_eval(&block) : block.call(self) if block_given? end |
Instance Method Details
#by(name, direction = nil) ⇒ Object
10 11 12 13 |
# File 'lib/tire/search/sort.rb', line 10 def by(name, direction=nil) @value << ( direction ? { name => direction } : name ) self end |
#to_ary ⇒ Object
15 16 17 |
# File 'lib/tire/search/sort.rb', line 15 def to_ary @value end |
#to_json(options = {}) ⇒ Object
19 20 21 |
# File 'lib/tire/search/sort.rb', line 19 def to_json(={}) @value.to_json end |