class ParamsReady::Query::NullnessPredicate

Public Class Methods

new(definition) click to toggle source
# File lib/params_ready/query/nullness_predicate.rb, line 10
def initialize(definition)
  super definition
  @data = definition.value_parameter.create
end

Public Instance Methods

build_query(select_expression, context: nil) click to toggle source
# File lib/params_ready/query/nullness_predicate.rb, line 15
def build_query(select_expression, context: nil)
  query = select_expression.eq(nil)
  if !unwrap
    query.not
  else
    query
  end
end
inspect_content() click to toggle source
# File lib/params_ready/query/nullness_predicate.rb, line 34
def inspect_content
  "#{definition.attribute_name} is_null? #{@data.inspect}"
end
perform_test(record, attribute_name) click to toggle source
# File lib/params_ready/query/nullness_predicate.rb, line 24
def perform_test(record, attribute_name)
  if unwrap
    return true if record.nil?
    record.send(attribute_name).nil?
  else
    return false if record.nil?
    !record.send(attribute_name).nil?
  end
end