Module: MongoMapper::Plugins::Dirty

Extended by:
ActiveSupport::Concern
Includes:
ActiveModel::Dirty
Included in:
Document
Defined in:
lib/mongo_mapper/plugins/dirty.rb

Instance Method Summary collapse

Instance Method Details

#initializeObject



9
10
11
12
# File 'lib/mongo_mapper/plugins/dirty.rb', line 9

def initialize(*)
  # never register initial id assignment as a change
  super.tap { changed_attributes.delete('_id') }
end

#initialize_from_databaseObject



14
15
16
# File 'lib/mongo_mapper/plugins/dirty.rb', line 14

def initialize_from_database(*)
  super.tap { changed_attributes.clear }
end

#reloadObject



22
23
24
# File 'lib/mongo_mapper/plugins/dirty.rb', line 22

def reload(*)
  super.tap { clear_changes }
end

#saveObject



18
19
20
# File 'lib/mongo_mapper/plugins/dirty.rb', line 18

def save(*)
  clear_changes { super }
end