Class: ParamsReady::Query::PolymorphPredicate
- Inherits:
-
Parameter::AbstractParameter
- Object
- Parameter::AbstractParameter
- ParamsReady::Query::PolymorphPredicate
- Includes:
- ParamsReady::Query::Predicate::DelegatingPredicate, ParamsReady::Query::Predicate::HavingChildren
- Defined in:
- lib/params_ready/query/polymorph_predicate.rb
Instance Attribute Summary
Attributes included from ParamsReady::Query::Predicate::DelegatingPredicate
Attributes inherited from Parameter::AbstractParameter
Instance Method Summary collapse
-
#initialize(definition, **_) ⇒ PolymorphPredicate
constructor
A new instance of PolymorphPredicate.
- #test(record) ⇒ Object
- #to_query(arel_table, context: Restriction.blanket_permission) ⇒ Object
Methods included from ParamsReady::Query::Predicate::HavingChildren
Methods included from ParamsReady::Query::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
Methods included from Extensions::Freezer::InstanceMethods
Constructor Details
#initialize(definition, **_) ⇒ PolymorphPredicate
Returns a new instance of PolymorphPredicate.
15 16 17 18 |
# File 'lib/params_ready/query/polymorph_predicate.rb', line 15 def initialize(definition, **_) super definition @data = definition.polymorph_parameter.create end |
Instance Method Details
#test(record) ⇒ Object
24 25 26 27 28 |
# File 'lib/params_ready/query/polymorph_predicate.rb', line 24 def test(record) return nil unless is_definite? data[data.type].test(record) end |
#to_query(arel_table, context: Restriction.blanket_permission) ⇒ Object
20 21 22 |
# File 'lib/params_ready/query/polymorph_predicate.rb', line 20 def to_query(arel_table, context: Restriction.) data[data.type].to_query_if_eligible(arel_table, context: context) end |