Module: Congo::Grip::HasAttachment
- Defined in:
- lib/congo/grip/has_attachment.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
28 29 30 |
# File 'lib/congo/grip/has_attachment.rb', line 28 def self.included(base) base.extend Congo::Grip::HasAttachment::ClassMethods end |
Instance Method Details
#destroy_attached_files ⇒ Object
92 93 94 95 96 |
# File 'lib/congo/grip/has_attachment.rb', line 92 def destroy_attached_files self.class..each do |name, | GridFS::GridStore.unlink(self.class.database, self["#{name}_path"]) end end |
#save_attachments ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/congo/grip/has_attachment.rb', line 80 def self.class..each do || name, file = if (file.is_a?(File) || file.is_a?(Tempfile)) GridFS::GridStore.open(self.class.database, self["#{name}_path"], 'w', :content_type => self["#{name}_content_type"]) do |f| f.write(file.read) end end end end |