Module: Familia::Features::Relationships::ModelInstanceMethods
- Defined in:
- lib/familia/features/relationships.rb
Instance Method Summary collapse
-
#cleanup_all_relationships! ⇒ Object
deprecated
Deprecated.
This method is poorly implemented and will be removed in v3.0. The participation collection removal logic was repetitive and difficult to debug. A cleaner implementation will be provided in a future version. See pull #115 for details.
-
#create_temp_key(base_name, ttl = 300) ⇒ Object
Instance method wrapper for create_temp_key.
-
#dbclient ⇒ Object
Direct Valkey/Redis access for instance methods.
-
#relationship_status ⇒ Object
Get comprehensive relationship status for this object.
-
#validate_relationships! ⇒ Object
Validate that this object's relationships are consistent.
Instance Method Details
#cleanup_all_relationships! ⇒ Object
This method is poorly implemented and will be removed in v3.0. The participation collection removal logic was repetitive and difficult to debug. A cleaner implementation will be provided in a future version. See pull #115 for details.
Currently only removes from indexes, not participation collections
Comprehensive cleanup - remove from all relationships
208 209 210 211 212 213 214 |
# File 'lib/familia/features/relationships.rb', line 208 def cleanup_all_relationships! warn '[DEPRECATED] cleanup_all_relationships! will be removed in v3.0. See pull #115.' warn 'Not currently removing from participation collections. Only indexes will be cleaned.' # Remove from indexes remove_from_all_indexes if respond_to?(:remove_from_all_indexes) end |
#create_temp_key(base_name, ttl = 300) ⇒ Object
Instance method wrapper for create_temp_key
242 243 244 245 246 247 248 249 250 251 |
# File 'lib/familia/features/relationships.rb', line 242 def create_temp_key(base_name, ttl = 300) = Familia.now.to_i random_suffix = SecureRandom.hex(3) temp_key = Familia.join('temp', base_name, , random_suffix) # UnsortedSet immediate expiry to ensure cleanup even if operation fails dbclient.expire(temp_key, ttl) temp_key end |
#dbclient ⇒ Object
Direct Valkey/Redis access for instance methods
237 238 239 |
# File 'lib/familia/features/relationships.rb', line 237 def dbclient self.class.dbclient end |
#relationship_status ⇒ Object
Get comprehensive relationship status for this object
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/familia/features/relationships.rb', line 184 def relationship_status status = { identifier: identifier, current_participations: [], index_memberships: [], } # Get participation memberships status[:current_participations] = current_participations if respond_to?(:current_participations) # Get index memberships status[:index_memberships] = current_indexings if respond_to?(:current_indexings) status end |
#validate_relationships! ⇒ Object
Validate that this object's relationships are consistent
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/familia/features/relationships.rb', line 217 def validate_relationships! errors = [] # Validate identifier exists errors << 'Object identifier is nil' unless identifier # Validate participation memberships if respond_to?(:current_participations) current_participations.each do |membership| score = membership[:score] errors << "Invalid score in participation membership: #{membership}" if score && !score.is_a?(Numeric) end end raise RelationshipError, "Relationship validation failed for #{self}: #{errors.join('; ')}" if errors.any? true end |