Class: Familia::Features::Relationships::IndexingRelationship

Inherits:
Data
  • Object
show all
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, in unique_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

Instance Method Summary collapse

Instance Attribute Details

#cardinalityObject (readonly)

Returns the value of attribute cardinality

Returns:

  • (Object)

    the current value of cardinality



28
29
30
# File 'lib/familia/features/relationships/indexing_relationship.rb', line 28

def cardinality
  @cardinality
end

#fieldObject (readonly)

Returns the value of attribute field

Returns:

  • (Object)

    the current value of field



28
29
30
# File 'lib/familia/features/relationships/indexing_relationship.rb', line 28

def field
  @field
end

#index_nameObject (readonly)

Returns the value of attribute index_name

Returns:

  • (Object)

    the current value of index_name



28
29
30
# File 'lib/familia/features/relationships/indexing_relationship.rb', line 28

def index_name
  @index_name
end

#queryObject (readonly)

Returns the value of attribute query

Returns:

  • (Object)

    the current value of query



28
29
30
# File 'lib/familia/features/relationships/indexing_relationship.rb', line 28

def query
  @query
end

#scope_classObject (readonly)

Returns the value of attribute scope_class

Returns:

  • (Object)

    the current value of scope_class



28
29
30
# File 'lib/familia/features/relationships/indexing_relationship.rb', line 28

def scope_class
  @scope_class
end

#withinObject (readonly)

Returns the value of attribute within

Returns:

  • (Object)

    the current value of 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.

Returns:

  • (Boolean)


54
55
56
# File 'lib/familia/features/relationships/indexing_relationship.rb', line 54

def class_level?
  within.nil? || within == :class
end

#scope_class_config_nameString

Get the normalized config name for the scope class

Returns:

  • (String)

    The config name (e.g., "user", "company", "test_company")



41
42
43
# File 'lib/familia/features/relationships/indexing_relationship.rb', line 41

def scope_class_config_name
  scope_class.config_name
end