Class: Tire::Search::Sort

Inherits:
Object
  • Object
show all
Defined in:
lib/tire/search/sort.rb

Instance Method Summary collapse

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_aryObject



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(options={})
  @value.to_json
end