Class: Familia::Features::Relationships::ParticipationRelationship
- Inherits:
-
Data
- Object
- Data
- Familia::Features::Relationships::ParticipationRelationship
- Defined in:
- lib/familia/features/relationships/participation_relationship.rb
Overview
target_class is resolved once at definition time for performance. Use _original_target for debugging/introspection to see what was passed.
ParticipationRelationship
Stores metadata about participation relationships defined at class level. Used to configure code generation and runtime behavior for participates_in and class_participates_in declarations.
Instance Attribute Summary collapse
-
#_original_target ⇒ Object
readonly
Returns the value of attribute _original_target.
-
#collection_name ⇒ Object
readonly
Returns the value of attribute collection_name.
-
#generate_participant_methods ⇒ Object
readonly
Returns the value of attribute generate_participant_methods.
-
#method_prefix ⇒ Object
readonly
Returns the value of attribute method_prefix.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
-
#staged ⇒ Object
readonly
Returns the value of attribute staged.
-
#target_class ⇒ Object
readonly
Returns the value of attribute target_class.
-
#through ⇒ Object
readonly
Returns the value of attribute through.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#matches?(comparison_target, comparison_collection) ⇒ Boolean
Check if this relationship matches the given target and collection Handles namespace-agnostic class comparison.
-
#resolved_through_class ⇒ Class?
Resolve the through class to an actual Class object.
-
#staged? ⇒ Boolean
Check if this relationship uses staged activation.
-
#staging_collection_name ⇒ Symbol?
Get the staging collection name.
-
#target_class_base ⇒ String
Get the base class name without namespace Handles anonymous class wrappers like "#Class:0x123::SymbolResolutionCustomer".
-
#through_model? ⇒ Boolean
Check if this relationship uses a through model.
-
#unique_key ⇒ String
Get a unique key for this participation relationship Useful for comparisons and hash keys.
Instance Attribute Details
#_original_target ⇒ Object (readonly)
Returns the value of attribute _original_target
18 19 20 |
# File 'lib/familia/features/relationships/participation_relationship.rb', line 18 def _original_target @_original_target end |
#collection_name ⇒ Object (readonly)
Returns the value of attribute collection_name
18 19 20 |
# File 'lib/familia/features/relationships/participation_relationship.rb', line 18 def collection_name @collection_name end |
#generate_participant_methods ⇒ Object (readonly)
Returns the value of attribute generate_participant_methods
18 19 20 |
# File 'lib/familia/features/relationships/participation_relationship.rb', line 18 def generate_participant_methods @generate_participant_methods end |
#method_prefix ⇒ Object (readonly)
Returns the value of attribute method_prefix
18 19 20 |
# File 'lib/familia/features/relationships/participation_relationship.rb', line 18 def method_prefix @method_prefix end |
#score ⇒ Object (readonly)
Returns the value of attribute score
18 19 20 |
# File 'lib/familia/features/relationships/participation_relationship.rb', line 18 def score @score end |
#staged ⇒ Object (readonly)
Returns the value of attribute staged
18 19 20 |
# File 'lib/familia/features/relationships/participation_relationship.rb', line 18 def staged @staged end |
#target_class ⇒ Object (readonly)
Returns the value of attribute target_class
18 19 20 |
# File 'lib/familia/features/relationships/participation_relationship.rb', line 18 def target_class @target_class end |
#through ⇒ Object (readonly)
Returns the value of attribute through
18 19 20 |
# File 'lib/familia/features/relationships/participation_relationship.rb', line 18 def through @through end |
#type ⇒ Object (readonly)
Returns the value of attribute type
18 19 20 |
# File 'lib/familia/features/relationships/participation_relationship.rb', line 18 def type @type end |
Instance Method Details
#matches?(comparison_target, comparison_collection) ⇒ Boolean
Check if this relationship matches the given target and collection Handles namespace-agnostic class comparison
51 52 53 54 55 56 57 58 |
# File 'lib/familia/features/relationships/participation_relationship.rb', line 51 def matches?(comparison_target, comparison_collection) # Normalize comparison target to base class name comparison_target = comparison_target.name if comparison_target.is_a?(Class) comparison_target_base = comparison_target.to_s.split('::').last target_class_base == comparison_target_base && collection_name == comparison_collection.to_sym end |
#resolved_through_class ⇒ Class?
Resolve the through class to an actual Class object
70 71 72 73 74 |
# File 'lib/familia/features/relationships/participation_relationship.rb', line 70 def resolved_through_class return nil unless through through.is_a?(Class) ? through : Familia.resolve_class(through) end |
#staged? ⇒ Boolean
Check if this relationship uses staged activation
79 80 81 |
# File 'lib/familia/features/relationships/participation_relationship.rb', line 79 def staged? !staged.nil? end |
#staging_collection_name ⇒ Symbol?
Get the staging collection name
86 87 88 |
# File 'lib/familia/features/relationships/participation_relationship.rb', line 86 def staging_collection_name staged end |
#target_class_base ⇒ String
Get the base class name without namespace Handles anonymous class wrappers like "#Class:0x123::SymbolResolutionCustomer"
41 42 43 |
# File 'lib/familia/features/relationships/participation_relationship.rb', line 41 def target_class_base target_class.name.split('::').last end |
#through_model? ⇒ Boolean
Check if this relationship uses a through model
63 64 65 |
# File 'lib/familia/features/relationships/participation_relationship.rb', line 63 def through_model? !through.nil? end |