| Module | Ribs::Repository::InstanceMethods |
| In: |
lib/ribs/repository.rb
|
InstanceMethods are those that become available when you the repository for a specific instance. This allows things like saving and destroying a specific instance.
Removes this instance from the database.
# File lib/ribs/repository.rb, line 139
139: def destroy!
140: self.class.destroyed(self.model)
141: Ribs.with_handle(self.database) do |h|
142: h.delete(self.model)
143: end
144: end
Get the meta data for this model
# File lib/ribs/repository.rb, line 134
134: def metadata
135: self.class.metadata
136: end
Saves this instance to the database. If the instance already exists, it will update the database, otherwise it will create it.
# File lib/ribs/repository.rb, line 149
149: def save
150: Ribs.with_handle(self.database) do |h|
151: if self.class.persistent?(self.model)
152: h.update_obj(self.model)
153: else
154: h.insert_obj(self.model)
155: self.class.persistent(self.model)
156: end
157: end
158: self.model
159: end