Class: Elasticquery::Filters::Exists

Inherits:
Base
  • Object
show all
Defined in:
lib/elasticquery/filters/exists.rb

Instance Method Summary collapse

Methods inherited from Base

#dup_with, #invalid?

Constructor Details

#initialize(field = nil) ⇒ Exists

Returns a new instance of Exists.



7
8
9
# File 'lib/elasticquery/filters/exists.rb', line 7

def initialize(field = nil)
  @field = field
end

Instance Method Details

#to_hashObject



15
16
17
# File 'lib/elasticquery/filters/exists.rb', line 15

def to_hash
  {exists: {field: @field}}
end

#to_not_hashObject



19
20
21
# File 'lib/elasticquery/filters/exists.rb', line 19

def to_not_hash
  {missing: {field: @field}}
end

#valid?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/elasticquery/filters/exists.rb', line 11

def valid?
  @field.present?
end