Class: Familia::Features::Relationships::IndexingRelationship
- Inherits:
-
Data
- Object
- Data
- Familia::Features::Relationships::IndexingRelationship
- Defined in:
- lib/familia/features/relationships/indexing_relationship.rb
Overview
IndexingRelationship
Stores metadata about indexing relationships defined at class level. Used to configure code generation and runtime behavior for unique_index and multi_index declarations.
Similar to ParticipationRelationship but for attribute-based lookups rather than collection membership.
Terminology:
scope_class: The class that provides the uniqueness boundary for instance-scoped indexes. For example, inunique_index :badge_number, :badge_index, within: Company, the Company is the scope class.within: Preserves the original DSL parameter to explicitly distinguish class-level indexes (within: nil) from instance-scoped indexes (within: SomeClass). This avoids brittle class comparisons and prevents issues with inheritance scenarios.
Instance Attribute Summary collapse
-
#cardinality ⇒ Object
readonly
Returns the value of attribute cardinality.
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#index_name ⇒ Object
readonly
Returns the value of attribute index_name.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#scope_class ⇒ Object
readonly
Returns the value of attribute scope_class.
-
#within ⇒ Object
readonly
Returns the value of attribute within.
Instance Method Summary collapse
-
#class_level? ⇒ Boolean
Whether this is a class-level index (as opposed to instance-scoped).
-
#scope_class_config_name ⇒ String
Get the normalized config name for the scope class.
Instance Attribute Details
#cardinality ⇒ Object (readonly)
Returns the value of attribute cardinality
28 29 30 |
# File 'lib/familia/features/relationships/indexing_relationship.rb', line 28 def cardinality @cardinality end |
#field ⇒ Object (readonly)
Returns the value of attribute field
28 29 30 |
# File 'lib/familia/features/relationships/indexing_relationship.rb', line 28 def field @field end |
#index_name ⇒ Object (readonly)
Returns the value of attribute index_name
28 29 30 |
# File 'lib/familia/features/relationships/indexing_relationship.rb', line 28 def index_name @index_name end |
#query ⇒ Object (readonly)
Returns the value of attribute query
28 29 30 |
# File 'lib/familia/features/relationships/indexing_relationship.rb', line 28 def query @query end |
#scope_class ⇒ Object (readonly)
Returns the value of attribute scope_class
28 29 30 |
# File 'lib/familia/features/relationships/indexing_relationship.rb', line 28 def scope_class @scope_class end |
#within ⇒ Object (readonly)
Returns the value of attribute within
28 29 30 |
# File 'lib/familia/features/relationships/indexing_relationship.rb', line 28 def within @within end |
Instance Method Details
#class_level? ⇒ Boolean
Whether this is a class-level index (as opposed to instance-scoped).
Class-level indexes live under the class and use within: nil
(unique_index default) or within: :class (multi_index class scope).
Instance-scoped indexes use within: SomeClass and require a scope
instance to populate or query.
54 55 56 |
# File 'lib/familia/features/relationships/indexing_relationship.rb', line 54 def class_level? within.nil? || within == :class end |
#scope_class_config_name ⇒ String
Get the normalized config name for the scope class
41 42 43 |
# File 'lib/familia/features/relationships/indexing_relationship.rb', line 41 def scope_class_config_name scope_class.config_name end |