Module: Hecks::Bluebook::Behaviour::ReadModel

Included in:
ReadModel
Defined in:
lib/hecks/bluebook/behaviour/read_model.rb

Overview

WHAT A READ MODEL DOES. Its declared half is the gathered heads and the query shape; these are readings taken off them.

Instance Method Summary collapse

Instance Method Details

#count?Boolean

!! rather than a bare @count — the DSL/reconstruction boundary (ReadModel#initialize) already normalises to true/nil, so this is belt and braces against a future caller constructing a ReadModel by hand with count: false.

Returns:

  • (Boolean)


13
# File 'lib/hecks/bluebook/behaviour/read_model.rb', line 13

def count? = !!@count

#filtered_head_nameObject

WHICH GATHERED HEAD THE FILTERING APPLIES TO, so the read-model interpreter can ask this directly rather than re-deriving or re-checking it.



20
21
22
23
24
25
# File 'lib/hecks/bluebook/behaviour/read_model.rb', line 20

def filtered_head_name
  return nil unless wheres.any? || order_by || limit || offset || authorization&.tenant ||
                    @group_by.any? || count? || @median_field

  @aggregate_heads.find { |head| head[:many] }&.fetch(:as)
end

#group_by_fieldsObject



7
# File 'lib/hecks/bluebook/behaviour/read_model.rb', line 7

def group_by_fields = @group_by.map { |row| row[:field].to_sym }

#query_nameObject



15
# File 'lib/hecks/bluebook/behaviour/read_model.rb', line 15

def query_name = Naming.snake(@name)