Class: Slingshot::Search::Sort
- Inherits:
-
Object
- Object
- Slingshot::Search::Sort
- Defined in:
- lib/slingshot/search/sort.rb
Instance Method Summary collapse
- #field(name, direction = nil) ⇒ Object
-
#initialize(&block) ⇒ Sort
constructor
A new instance of Sort.
- #method_missing(id, *args, &block) ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(&block) ⇒ Sort
Returns a new instance of Sort.
5 6 7 8 |
# File 'lib/slingshot/search/sort.rb', line 5 def initialize(&block) @value = [] self.instance_eval(&block) if block_given? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
Instance Method Details
#field(name, direction = nil) ⇒ Object
10 11 12 13 |
# File 'lib/slingshot/search/sort.rb', line 10 def field(name, direction=nil) @value << ( direction ? { name => direction } : name ) self end |
#to_json ⇒ Object
23 24 25 |
# File 'lib/slingshot/search/sort.rb', line 23 def to_json @value.to_json end |