Module: MotionRecord::Persistence

Included in:
Base
Defined in:
lib/motion_record/persistence.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

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



20
21
22
# File 'lib/motion_record/persistence.rb', line 20

def mark_persisted!
  @persisted = true
end

#mark_unpersisted!Object



24
25
26
# File 'lib/motion_record/persistence.rb', line 24

def mark_unpersisted!
  @persisted = false
end

#persisted?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/motion_record/persistence.rb', line 16

def persisted?
  !!@persisted
end

#save!Object



4
5
6
# File 'lib/motion_record/persistence.rb', line 4

def save!
  persist!
end