Class: Slingshot::Search::Filter

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

Overview

Instance Method Summary collapse

Constructor Details

#initialize(type, *options) ⇒ Filter

Returns a new instance of Filter.



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

def initialize(type, *options)
  value = if options.size < 2
    options.first || {}
  else
    options # An +or+ filter encodes multiple filters as an array
  end
  @hash = { type => value }
end

Instance Method Details

#to_hashObject



22
23
24
# File 'lib/slingshot/search/filter.rb', line 22

def to_hash
  @hash
end

#to_jsonObject



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

def to_json
  to_hash.to_json
end