Module: Mongo::Model::FileModel::ClassMethods
- Defined in:
- lib/mongo/model/integration/file_model.rb
Instance Method Summary collapse
Instance Method Details
#mount_file(attr_name, file_model_class) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mongo/model/integration/file_model.rb', line 15 def mount_file attr_name, file_model_class super before_validate do |model| file_model = model.send(attr_name) file_model.run_validations model.errors[attr_name] = file_model.errors unless file_model.errors.empty? end after_save{|model| model.send(attr_name).save!} after_delete{|model| model.send(attr_name).delete!} end |