Module: MotionRecord::Persistence
- Included in:
- Base
- Defined in:
- lib/motion_record/persistence.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #delete! ⇒ Object
- #mark_persisted! ⇒ Object
- #mark_unpersisted! ⇒ Object
- #persisted? ⇒ Boolean
- #primary_key_condition ⇒ Object
- #save! ⇒ Object
Instance Method Details
#delete! ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/motion_record/persistence.rb', line 8 def delete! if persisted? self.class.where(primary_key_condition).delete_all else raise "Can't delete unpersisted records" end end |
#mark_persisted! ⇒ Object
24 25 26 |
# File 'lib/motion_record/persistence.rb', line 24 def mark_persisted! @persisted = true end |
#mark_unpersisted! ⇒ Object
28 29 30 |
# File 'lib/motion_record/persistence.rb', line 28 def mark_unpersisted! @persisted = false end |
#persisted? ⇒ Boolean
20 21 22 |
# File 'lib/motion_record/persistence.rb', line 20 def persisted? !!@persisted end |
#primary_key_condition ⇒ Object
16 17 18 |
# File 'lib/motion_record/persistence.rb', line 16 def primary_key_condition {self.class.primary_key => self.instance_variable_get("@#{self.class.primary_key}")} end |
#save! ⇒ Object
4 5 6 |
# File 'lib/motion_record/persistence.rb', line 4 def save! persist! end |