Class: Gluttonberg::AssetType
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Gluttonberg::AssetType
- Defined in:
- app/models/gluttonberg/asset_type.rb
Class Method Summary collapse
- .build_defaults ⇒ Object
-
.for_file(mime_type, file_name) ⇒ Object
Take the reported mime-type and the file_name and return the best AssetType to use for that file.
Class Method Details
.build_defaults ⇒ Object
37 38 39 |
# File 'app/models/gluttonberg/asset_type.rb', line 37 def self.build_defaults Library::build_default_asset_types end |
.for_file(mime_type, file_name) ⇒ Object
Take the reported mime-type and the file_name and return the best AssetType to use for that file.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/models/gluttonberg/asset_type.rb', line 20 def self.for_file(mime_type, file_name) mime_types = self.find_mime_type_string(mime_type, file_name) # OK, we really have no idea what this is if mime_types.blank? file_mime_type = mime_type file_base_type = mime_type.split('/').first else # multiple mime-types may be returned, but we only want to work with # one, so pick the first one file_mime_type = mime_types.first.content_type file_base_type = mime_types.first.raw_media_type end self.gb_mime_type_object(file_mime_type, file_base_type) end |