Module: Believer::Relation::CollectionMethods
- Included in:
- Collection
- Defined in:
- lib/believer/relation.rb
Instance Method Summary collapse
Instance Method Details
#clear ⇒ Object
98 99 100 |
# File 'lib/believer/relation.rb', line 98 def clear destroy(*(to_a.dup)) end |
#create(attrs = {}) ⇒ Object
112 113 114 115 |
# File 'lib/believer/relation.rb', line 112 def create(attrs = {}) obj = record_class.create(attrs) loaded_objects << obj end |
#destroy(*objects) ⇒ Object
102 103 104 105 106 107 108 109 110 |
# File 'lib/believer/relation.rb', line 102 def destroy(*objects) return if loaded_objects.nil? || loaded_objects.empty? objects.each do |obj| if loaded_objects.include?(obj) obj.destroy loaded_objects.delete(obj) end end end |