Class: Hecks::Bluebook::DSL::QueryBuilder
- Inherits:
-
Object
- Object
- Hecks::Bluebook::DSL::QueryBuilder
- Defined in:
- lib/hecks/bluebook/dsl/query_builder.rb
Constant Summary collapse
- GRAMMAR_CONTEXT =
"Query"
Constants included from WordGate
Class Method Summary collapse
Instance Method Summary collapse
- #build ⇒ Object
- #description(value) ⇒ Object
-
#initialize(name) ⇒ QueryBuilder
constructor
A new instance of QueryBuilder.
-
#reference_to_impl(type, as: nil, optional: false) ⇒ Object
A query parameter naming another aggregate's own identity (Card.Active's own
Board, filtering to one board's cards) — just a plain attribute typed as a reference, AttributeCollector#attribute already handling an Reference exactly like any other.
Methods included from QuerySpecification::Common::DSL
#authorize_impl, #cursor, #inspect_query, #limit_impl, #nulls, #offset_impl, #order_by_impl, #where_impl
Methods included from AttributeCollector
#attribute_impl, #attributes, #closed_sets, #list_of_impl, #one_of_impl
Constructor Details
#initialize(name) ⇒ QueryBuilder
Returns a new instance of QueryBuilder.
12 13 14 15 |
# File 'lib/hecks/bluebook/dsl/query_builder.rb', line 12 def initialize(name) @name = name @wheres = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Hecks::Bluebook::DSL::WordGate
Class Method Details
.build(name, owner_attributes: [], &block) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/hecks/bluebook/dsl/query_builder.rb', line 51 def self.build(name, owner_attributes: [], &block) builder = new(name) builder.instance_eval(&block) if block # `send`, not a public call — this isn't a bluebook DSL word (no # author ever writes `derive_from_owner!` inside a query block), # just internal wiring between this class method and the instance # it just built. Kept private below so syntax_conformance_spec's # own "every word QueryBuilder answers is declared" check doesn't # mistake it for one. builder.send(:derive_from_owner!, owner_attributes, block) if block builder.build end |
Instance Method Details
#build ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/hecks/bluebook/dsl/query_builder.rb', line 34 def build seal_cursor Query.new( name: @name, description: @description, attributes: attributes, wheres: @wheres, order_by: @order_by, limit: @limit, offset: @offset, cursor: @cursor, authorization: @authorization, null_semantics: @null_semantics, inspection: @inspection ) end |
#description(value) ⇒ Object
17 |
# File 'lib/hecks/bluebook/dsl/query_builder.rb', line 17 def description(value) = @description = value |
#reference_to_impl(type, as: nil, optional: false) ⇒ Object
A query parameter naming another aggregate's own identity
(Card.Active's own Board, filtering to one board's cards) —
just a plain attribute typed as a reference,
AttributeCollector#attribute already handling an Reference
exactly like any other. No "acts on itself" case to
distinguish here the way a command's own reference_to has —
a query has no root of its own to act on, only parameters.
RENAMED FROM reference_to — item #13's full metaprogrammed
dispatch (slice 4b). Bootstrap-reachable, in
GenericDispatch::BOOTSTRAP_CALLS_FALLBACK.
29 30 31 32 |
# File 'lib/hecks/bluebook/dsl/query_builder.rb', line 29 def reference_to_impl(type, as: nil, optional: false) target = Naming.demodulise(type) attribute_impl(as || default_reference_name(target), Reference.new(target), optional: optional) end |