class ParamsReady::Query::VariableOperatorPredicate

Public Class Methods

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

Public Instance Methods

build_query(select_expression, context: nil) click to toggle source
# File lib/params_ready/query/variable_operator_predicate.rb, line 18
def build_query(select_expression, context: nil)
  operator.to_query(select_expression, value)
end
inspect_content() click to toggle source
# File lib/params_ready/query/variable_operator_predicate.rb, line 34
def inspect_content
  op, val = if is_definite?
    @data[:operator].unwrap_or(nil)&.name || '?'
    @data[:value].unwrap_or('?')
  else
    %w[? ?]
  end
  "#{definition.attribute_name} #{op} #{val}"
end
operator() click to toggle source
# File lib/params_ready/query/variable_operator_predicate.rb, line 30
def operator
  @data[:operator].unwrap
end
perform_test(record, attribute_name) click to toggle source
# File lib/params_ready/query/variable_operator_predicate.rb, line 22
def perform_test(record, attribute_name)
  operator.test(record, attribute_name, value)
end
value() click to toggle source
# File lib/params_ready/query/variable_operator_predicate.rb, line 26
def value
  @data[:value].unwrap
end