Class: Pluckr::Schema::Exists
- Includes:
- Conditions
- Defined in:
- lib/pluckr/schema/exists.rb
Overview
exists :photos -> correlated EXISTS (SELECT 1 FROM photos WHERE ...)
Instance Attribute Summary collapse
-
#association ⇒ Object
readonly
Returns the value of attribute association.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#where ⇒ Object
readonly
Returns the value of attribute where.
Attributes inherited from Node
Instance Method Summary collapse
-
#initialize(output:, association:, where: nil, scope: nil) ⇒ Exists
constructor
A new instance of Exists.
- #relation_scoped? ⇒ Boolean
- #target_model ⇒ Object
Methods included from Conditions
#dynamic_where?, #resolved_where
Methods inherited from Node
Constructor Details
#initialize(output:, association:, where: nil, scope: nil) ⇒ Exists
Returns a new instance of Exists.
11 12 13 14 15 16 17 |
# File 'lib/pluckr/schema/exists.rb', line 11 def initialize(output:, association:, where: nil, scope: nil) super(output: output) @association = association @where = where.respond_to?(:call) ? where : where&.dup&.freeze @scope = scope freeze end |
Instance Attribute Details
#association ⇒ Object (readonly)
Returns the value of attribute association.
9 10 11 |
# File 'lib/pluckr/schema/exists.rb', line 9 def association @association end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
9 10 11 |
# File 'lib/pluckr/schema/exists.rb', line 9 def scope @scope end |
#where ⇒ Object (readonly)
Returns the value of attribute where.
9 10 11 |
# File 'lib/pluckr/schema/exists.rb', line 9 def where @where end |
Instance Method Details
#relation_scoped? ⇒ Boolean
23 24 25 |
# File 'lib/pluckr/schema/exists.rb', line 23 def relation_scoped? !scope.nil? || !where.nil? end |
#target_model ⇒ Object
19 20 21 |
# File 'lib/pluckr/schema/exists.rb', line 19 def target_model association.klass end |