Class: DataMapper::Associations::OneToMany::Collection
- Inherits:
-
Collection
- Object
- LazyArray
- Collection
- DataMapper::Associations::OneToMany::Collection
- Defined in:
- lib/dm-core/associations/one_to_many.rb
Overview
class Relationship
Direct Known Subclasses
Instance Attribute Summary collapse
- #relationship ⇒ Object private
- #source ⇒ Object private
Attributes inherited from Collection
Attributes inherited from LazyArray
Instance Method Summary collapse
-
#clear ⇒ Collection
Removes all Resources from the 1:m Collection.
-
#destroy ⇒ Boolean
Remove every Resource in the 1:m Collection from the repository.
-
#destroy! ⇒ Boolean
Remove every Resource in the 1:m Collection from the repository, bypassing validation.
- #reload ⇒ Object
-
#replace ⇒ Collection
Replace the Resources within the 1:m Collection.
-
#update ⇒ Boolean
Update every Resource in the 1:m Collection.
-
#update! ⇒ Boolean
Update every Resource in the 1:m Collection, bypassing validation.
Methods inherited from Collection
#<<, #[], #[]=, #all, #at, #clean?, #collect!, #concat, #create, #create!, #delete, #delete_at, #delete_if, #difference, #dirty?, #each, #first, #first_or_create, #first_or_new, #get, #get!, #hash, #insert, #inspect, #intersection, #last, #loaded_entries, #model, #model_key, #new, #pop, #properties, #push, #reject!, #relationships, #repository, #respond_to?, #reverse, #reverse!, #save, #save!, #set, #shift, #slice!, #union, #unshift
Methods inherited from LazyArray
#<<, #==, #[], #[]=, #any?, #at, #concat, #delete_at, #delete_if, #empty?, #eql?, #fetch, #first, #freeze, #frozen?, #include?, #index, #insert, #kind_of?, #last, #lazy_possible?, #load_with, #loaded?, #pop, #push, #respond_to?, #reverse, #reverse!, #shift, #slice!, #to_a, #unshift, #values_at
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class DataMapper::Collection
Instance Attribute Details
#relationship ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
165 166 167 |
# File 'lib/dm-core/associations/one_to_many.rb', line 165 def relationship @relationship end |
#source ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
168 169 170 |
# File 'lib/dm-core/associations/one_to_many.rb', line 168 def source @source end |
Instance Method Details
#clear ⇒ Collection
Removes all Resources from the 1:m Collection
This should remove and orphan each Resource from the 1:m Collection.
198 199 200 201 |
# File 'lib/dm-core/associations/one_to_many.rb', line 198 def clear lazy_load # lazy load so that targets are always orphaned super end |
#destroy ⇒ Boolean
Remove every Resource in the 1:m Collection from the repository
This performs a deletion of each Resource in the Collection from the repository and clears the Collection.
240 241 242 243 |
# File 'lib/dm-core/associations/one_to_many.rb', line 240 def destroy assert_source_saved 'The source must be saved before mass-deleting the collection' super end |
#destroy! ⇒ Boolean
Remove every Resource in the 1:m Collection from the repository, bypassing validation
This performs a deletion of each Resource in the Collection from the repository and clears the Collection while skipping validation.
255 256 257 258 |
# File 'lib/dm-core/associations/one_to_many.rb', line 255 def destroy! assert_source_saved 'The source must be saved before mass-deleting the collection' super end |
#reload ⇒ Object
171 172 173 174 |
# File 'lib/dm-core/associations/one_to_many.rb', line 171 def reload(*) assert_source_saved 'The source must be saved before reloading the collection' super end |
#replace ⇒ Collection
Replace the Resources within the 1:m Collection
185 186 187 188 |
# File 'lib/dm-core/associations/one_to_many.rb', line 185 def replace(*) lazy_load # lazy load so that targets are always orphaned super end |
#update ⇒ Boolean
Update every Resource in the 1:m Collection
212 213 214 215 |
# File 'lib/dm-core/associations/one_to_many.rb', line 212 def update(*) assert_source_saved 'The source must be saved before mass-updating the collection' super end |
#update! ⇒ Boolean
Update every Resource in the 1:m Collection, bypassing validation
226 227 228 229 |
# File 'lib/dm-core/associations/one_to_many.rb', line 226 def update!(*) assert_source_saved 'The source must be saved before mass-updating the collection' super end |