Module: Adrift::Integration::ActiveRecord
- Includes:
- Base
- Defined in:
- lib/adrift/integration/active_record.rb
Overview
Integrates Adrift with ActiveRecord.
Class Method Summary collapse
-
.install ⇒ Object
Integrates Adrift with ActiveRecord if it has been loaded.
Instance Method Summary collapse
-
#attachment ⇒ Object
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.
Methods included from Base
Class Method Details
.install ⇒ Object
Integrates Adrift with ActiveRecord if it has been loaded.
19 20 21 22 23 |
# File 'lib/adrift/integration/active_record.rb', line 19 def self.install if defined?(::ActiveRecord::Base) ::ActiveRecord::Base.send(:extend, self) end end |
Instance Method Details
#attachment ⇒ Object
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/active_record.rb', line 12 def (*) super after_save :save_attachments before_destroy :destroy_attachments end |