Module: TypedEAV::Partition
- Defined in:
- lib/typed_eav/partition.rb
Overview
Partition-aware visibility for schema objects keyed by the canonical ‘(entity_type, scope, parent_scope)` tuple.
This module is deliberately explicit: callers pass already-resolved scope values. Ambient resolution (‘TypedEAV.current_scope`, `with_scope`, `unscoped`) stays with the adapters that know their calling context.
Class Method Summary collapse
-
.effective_fields_by_name(entity_type:, scope: nil, parent_scope: nil, mode: :partition) ⇒ Object
One visible field per name after collision resolution.
- .find_visible_section!(id, entity_type:, scope: nil, parent_scope: nil, mode: :partition) ⇒ Object
-
.visible_fields(entity_type:, scope: nil, parent_scope: nil, mode: :partition) ⇒ Object
All field definitions visible from a tuple: pure global rows, scope-only rows, and full-tuple rows.
-
.visible_sections(entity_type:, scope: nil, parent_scope: nil, mode: :partition) ⇒ Object
All sections visible from the same tuple as field definitions.
Class Method Details
.effective_fields_by_name(entity_type:, scope: nil, parent_scope: nil, mode: :partition) ⇒ Object
One visible field per name after collision resolution. Most-specific wins: full tuple beats scope-only, scope-only beats global.
26 27 28 29 30 31 32 33 |
# File 'lib/typed_eav/partition.rb', line 26 def effective_fields_by_name(entity_type:, scope: nil, parent_scope: nil, mode: :partition) fields = visible_fields(entity_type: entity_type, scope: scope, parent_scope: parent_scope, mode: mode) if mode == :all_partitions TypedEAV::HasTypedEAV.definitions_multimap_by_name(fields) else TypedEAV::HasTypedEAV.definitions_by_name(fields) end end |
.find_visible_section!(id, entity_type:, scope: nil, parent_scope: nil, mode: :partition) ⇒ Object
44 45 46 |
# File 'lib/typed_eav/partition.rb', line 44 def find_visible_section!(id, entity_type:, scope: nil, parent_scope: nil, mode: :partition) visible_sections(entity_type: entity_type, scope: scope, parent_scope: parent_scope, mode: mode).find(id) end |
.visible_fields(entity_type:, scope: nil, parent_scope: nil, mode: :partition) ⇒ Object
All field definitions visible from a tuple: pure global rows, scope-only rows, and full-tuple rows. Passing mode: :all_partitions is the deliberate admin bypass; it is distinct from ‘scope: nil`, which means the global partition only.
16 17 18 19 20 21 22 |
# File 'lib/typed_eav/partition.rb', line 16 def visible_fields(entity_type:, scope: nil, parent_scope: nil, mode: :partition) validate_mode!(mode) return TypedEAV::Field::Base.where(entity_type: entity_type) if mode == :all_partitions validate_tuple!(scope, parent_scope) TypedEAV::Field::Base.for_entity(entity_type, scope: scope, parent_scope: parent_scope) end |
.visible_sections(entity_type:, scope: nil, parent_scope: nil, mode: :partition) ⇒ Object
All sections visible from the same tuple as field definitions.
36 37 38 39 40 41 42 |
# File 'lib/typed_eav/partition.rb', line 36 def visible_sections(entity_type:, scope: nil, parent_scope: nil, mode: :partition) validate_mode!(mode) return TypedEAV::Section.where(entity_type: entity_type) if mode == :all_partitions validate_tuple!(scope, parent_scope) TypedEAV::Section.for_entity(entity_type, scope: scope, parent_scope: parent_scope) end |