Class: Slingshot::Search::Sort

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

Instance Method Summary collapse

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

#method_missing(id, *args, &block) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/slingshot/search/sort.rb', line 10

def method_missing(id, *args, &block)
  case arg = args.shift
    when String, Symbol, Hash then @value << { id => arg }
    else @value << id
  end
  self
end

Instance Method Details

#to_jsonObject



18
19
20
# File 'lib/slingshot/search/sort.rb', line 18

def to_json
  @value.to_json
end