Module: Adrift::Integration::DataMapper

Includes:
Base
Defined in:
lib/adrift/integration/data_mapper.rb

Overview

Integrates Adrift with DataMapper.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base

#attachment_definitions

Class Method Details

.installObject

Integrates Adrift with DataMapper if it has been loaded.



19
20
21
22
23
# File 'lib/adrift/integration/data_mapper.rb', line 19

def self.install
  if defined?(::DataMapper::Model)
    ::DataMapper::Model.append_extensions(self) 
  end
end

Instance Method Details

#attachmentObject

Does everything Base#attachment does, but it also registers the callbacks to save the attachments when the model is saved, and to destroy them, when it is destroyed.



12
13
14
15
16
# File 'lib/adrift/integration/data_mapper.rb', line 12

def attachment(*)
  super
  after  :save,    :save_attachments
  before :destroy, :destroy_attachments
end