Module: Rid::Attachments
- Included in:
- Document
- Defined in:
- lib/rid/attachments.rb
Constant Summary collapse
- MIME_TYPE_MAPPING =
Mime type mapping from extensions
{ ".htm" => "text/html", ".html" => "text/html", ".js" => "text/javascript", ".css" => "text/css", ".manifest" => "text/cache-manifest", ".png" => "image/png", ".gif" => "image/gif", ".ico" => "image/x-icon", }
Instance Method Summary collapse
-
#map_attachments! ⇒ Object
encode attachments and add meta data.
-
#reduce_attachments! ⇒ Object
decode attachments and flatten meta data hash.
Instance Method Details
#map_attachments! ⇒ Object
encode attachments and add meta data
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rid/attachments.rb', line 18 def return if .empty? doc = {} .flatten.each do |key, value| doc[key] = { "data" => (value), "content_type" => mime_type_for(key) } end self. = doc end |
#reduce_attachments! ⇒ Object
decode attachments and flatten meta data hash
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rid/attachments.rb', line 34 def return if .empty? doc = {} .each do |key, value| data = value["data"] next unless data doc[key] = (data) end self. = doc end |