Module: Tenacity::OrmExt::DataMapper::InstanceMethods

Includes:
Helpers
Defined in:
lib/tenacity/orm_ext/datamapper.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods included from Helpers

#_t_serialize_id_for_sql, #_t_serialize_ids, #id_class_for

Instance Method Details

#_t_reloadObject



136
137
138
139
# File 'lib/tenacity/orm_ext/datamapper.rb', line 136

def _t_reload
  reload
  self.class._t_find(self.id)
end

#_t_save_if_dirty(*args) ⇒ Object



141
142
143
# File 'lib/tenacity/orm_ext/datamapper.rb', line 141

def _t_save_if_dirty(*args)
  dirty? ? save(*args) : true
end

#saveObject

DataMapper will not issue callbacks unless at least one of the properties is dirty. So, taint the object by marking one of the attributes as dirty, save the object, and resture the persisted_state by reloading the object from the database.



128
129
130
131
132
133
134
# File 'lib/tenacity/orm_ext/datamapper.rb', line 128

def save
  if clean?
    taint!; super; reload
  else
    super
  end
end