Module: ParamsReady::Query::Predicate::HavingAttribute

Extended by:
Forwardable
Includes:
HavingAssociations
Included in:
FixedOperatorPredicate, NullnessPredicate, VariableOperatorPredicate
Defined in:
lib/params_ready/query/predicate.rb

Instance Method Summary collapse

Methods included from HavingAssociations

#dig

Instance Method Details

#context_for_predicates(context) ⇒ Object



113
114
115
116
117
# File 'lib/params_ready/query/predicate.rb', line 113

def context_for_predicates(context)
  # We consider a an attribute having parameter atomic
  # so it's permitted per se including its contents
  context.permit_all
end

#test(record) ⇒ Object



119
120
121
122
123
124
125
126
# File 'lib/params_ready/query/predicate.rb', line 119

def test(record)
  return nil unless is_definite?

  attribute_name = definition.attribute_name
  record = dig(record, definition.associations)

  perform_test(record, attribute_name)
end

#to_query(arel_table, context: Restriction.blanket_permission) ⇒ Object



107
108
109
110
111
# File 'lib/params_ready/query/predicate.rb', line 107

def to_query(arel_table, context: Restriction.blanket_permission)
  table = definition.arel_table || arel_table
  select_expression = build_select_expression(table, context)
  build_query(select_expression, context: context)
end