Module: Persistence::Object::Complex::ClassAndObjectInstance
- Includes:
- CascadingConfiguration::Hash
- Included in:
- ClassInstance, ObjectInstance
- Defined in:
- lib/persistence/object/complex/class_and_object_instance.rb
Overview
Methods applied to both Class and Object instances of complex objects enabled with persistence capabilities.
Instance Method Summary collapse
-
#attr_delete_cascades(attribute_name, ...) ⇒ Object
Declare that deleting object should also delete attribute(s).
-
#attr_delete_cascades! ⇒ Object
Declare that deleting object should also delete declared attributes.
-
#attr_delete_cascades(attribute_name, ...) ⇒ Object
Declare that deleting object should not delete attribute(s).
-
#attr_delete_does_not_cascade! ⇒ Object
Declare that deleting object should not delete declared attributes.
-
#delete_cascades ⇒ CompositingHash{Symbol,String=>true,false}
Hash containing cascading delete data for attributes.
-
#delete_cascades?(attribute_name) ⇒ true, false
Query whether deleting object will also delete attribute.
Instance Method Details
#attr_delete_cascades(attribute_name, ...) ⇒ Object
Declare that deleting object should also delete attribute(s).
32 33 34 35 36 37 38 39 40 |
# File 'lib/persistence/object/complex/class_and_object_instance.rb', line 32 def attr_delete_cascades( *attributes ) attributes.each do |this_attribute| delete_cascades[ this_attribute.accessor_name ] = true end return self end |
#attr_delete_cascades! ⇒ Object
Declare that deleting object should also delete declared attributes.
74 75 76 77 78 |
# File 'lib/persistence/object/complex/class_and_object_instance.rb', line 74 def attr_delete_cascades! return attr_delete_cascades( *persistent_attributes.keys ) end |
#attr_delete_cascades(attribute_name, ...) ⇒ Object
Declare that deleting object should not delete attribute(s).
55 56 57 58 59 60 61 62 63 |
# File 'lib/persistence/object/complex/class_and_object_instance.rb', line 55 def attr_delete_does_not_cascade( *attributes ) attributes.each do |this_attribute| delete_cascades[ this_attribute.accessor_name ] = false end return self end |
#attr_delete_does_not_cascade! ⇒ Object
Declare that deleting object should not delete declared attributes.
90 91 92 93 94 |
# File 'lib/persistence/object/complex/class_and_object_instance.rb', line 90 def attr_delete_does_not_cascade! return attr_delete_does_not_cascade( *persistent_attributes.keys ) end |
#delete_cascades ⇒ CompositingHash{Symbol,String=>true,false}
Returns Hash containing cascading delete data for attributes.
21 |
# File 'lib/persistence/object/complex/class_and_object_instance.rb', line 21 attr_configuration_hash :delete_cascades |
#delete_cascades?(attribute_name) ⇒ true, false
Query whether deleting object will also delete attribute
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/persistence/object/complex/class_and_object_instance.rb', line 107 def delete_cascades?( attribute_name ) should_cascade = false accessor_name = attribute_name.accessor_name # delete_cascades is a cascading array that automatically handles inheritance if ( should_cascade = delete_cascades[ accessor_name ] ) == nil if attribute_value = persistence_port.get_attribute( self, accessor_name ) and attribute_value.is_a?( ::Persistence::Object::Complex::ComplexObject ) should_cascade = attribute_value.delete_cascades? end should_cascade = true if should_cascade.nil? delete_cascades[ accessor_name ] = should_cascade end return should_cascade end |