Class: Pluckr::Schema::One
Overview
one :plan, via: :subscription do ... end
Compiles to a LEFT OUTER JOIN plus a hidden presence marker so that "association missing" and "association present with NULL columns" stay distinguishable.
first :comment, via: :comments do ... end and its last counterpart use
the same node with pick and order set: one row out of a collection,
compiled as correlated subqueries instead of a join.
Instance Attribute Summary collapse
-
#association ⇒ Object
readonly
Returns the value of attribute association.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#pick ⇒ Object
readonly
Returns the value of attribute pick.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Attributes inherited from Node
Instance Method Summary collapse
-
#initialize(output:, association:, scope:, pick: nil, order: nil) ⇒ One
constructor
A new instance of One.
-
#picked? ⇒ Boolean
True when this node picks one row out of many rather than following a singular association.
- #scalar? ⇒ Boolean
Constructor Details
#initialize(output:, association:, scope:, pick: nil, order: nil) ⇒ One
Returns a new instance of One.
17 18 19 20 21 22 23 24 |
# File 'lib/pluckr/schema/one.rb', line 17 def initialize(output:, association:, scope:, pick: nil, order: nil) super(output: output) @association = association @scope = scope @pick = pick @order = order&.freeze freeze end |
Instance Attribute Details
#association ⇒ Object (readonly)
Returns the value of attribute association.
15 16 17 |
# File 'lib/pluckr/schema/one.rb', line 15 def association @association end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
15 16 17 |
# File 'lib/pluckr/schema/one.rb', line 15 def order @order end |
#pick ⇒ Object (readonly)
Returns the value of attribute pick.
15 16 17 |
# File 'lib/pluckr/schema/one.rb', line 15 def pick @pick end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
15 16 17 |
# File 'lib/pluckr/schema/one.rb', line 15 def scope @scope end |
Instance Method Details
#picked? ⇒ Boolean
True when this node picks one row out of many rather than following a singular association.
28 29 30 |
# File 'lib/pluckr/schema/one.rb', line 28 def picked? !pick.nil? end |
#scalar? ⇒ Boolean
32 33 34 |
# File 'lib/pluckr/schema/one.rb', line 32 def scalar? false end |