Class: Mongoid::QueryStringInterface::Parsers::BooleanAndNilParser

Inherits:
Object
  • Object
show all
Defined in:
lib/mongoid/parsers/boolean_and_nil_parser.rb

Instance Method Summary collapse

Instance Method Details

#parse(value) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/mongoid/parsers/boolean_and_nil_parser.rb', line 9

def parse(value)
  if boolean?(value)
    value.strip == 'true'
  elsif value.nil? or value.empty? or nil_value?(value)
    nil
  else
    value
  end
end

#parseable?(value, operator) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/mongoid/parsers/boolean_and_nil_parser.rb', line 5

def parseable?(value, operator)
  !value.nil? && !value.empty?
end