Class: ParamsReady::Query::FixedOperatorPredicate

Inherits:
Parameter::AbstractParameter show all
Includes:
Predicate::DelegatingPredicate, Predicate::HavingAttribute
Defined in:
lib/params_ready/query/fixed_operator_predicate.rb

Instance Attribute Summary

Attributes included from Predicate::DelegatingPredicate

#data

Attributes inherited from Parameter::AbstractParameter

#definition

Instance Method Summary collapse

Methods included from Predicate::HavingAttribute

#context_for_predicates, #test, #to_query

Methods included from Predicate::HavingAssociations

#dig

Methods included from Predicate::DelegatingPredicate

#eligible_for_query?, included, #to_query_if_eligible

Methods inherited from Parameter::AbstractParameter

#==, #dup, #inspect, intent_for_children, #match?, #populate, #to_hash, #update_if_applicable, #update_in

Methods included from Extensions::Freezer

#freeze_variable, #freeze_variables, #variables_to_freeze

Methods included from Parameter::FromHash

#set_from_hash

Methods included from Extensions::Freezer::InstanceMethods

#freeze

Constructor Details

#initialize(definition, **options) ⇒ FixedOperatorPredicate

Returns a new instance of FixedOperatorPredicate.



14
15
16
17
# File 'lib/params_ready/query/fixed_operator_predicate.rb', line 14

def initialize(definition, **options)
  super definition
  @data = definition.type.create
end

Instance Method Details

#build_query(select_expression, context: nil) ⇒ Object



19
20
21
# File 'lib/params_ready/query/fixed_operator_predicate.rb', line 19

def build_query(select_expression, context: nil)
  definition.operator.to_query(select_expression, @data.unwrap)
end

#inspect_contentObject



27
28
29
30
# File 'lib/params_ready/query/fixed_operator_predicate.rb', line 27

def inspect_content
  op = definition.operator.name
  "#{definition.attribute_name} #{op} #{@data.inspect}"
end

#perform_test(record, attribute_name) ⇒ Object



23
24
25
# File 'lib/params_ready/query/fixed_operator_predicate.rb', line 23

def perform_test(record, attribute_name)
  definition.operator.test(record, attribute_name, @data.unwrap)
end