Class: MyFile

Inherits:
File
  • Object
show all
Defined in:
app/controllers/gluttonberg/admin/asset_library/assets_controller.rb

Overview

but we are adding assets from file, i am injecting extra attributes manually. because asset library assumes that file has three extra attributes

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#content_typeObject

Returns the value of attribute content_type.



352
353
354
# File 'app/controllers/gluttonberg/admin/asset_library/assets_controller.rb', line 352

def content_type
  @content_type
end

#original_filenameObject

Returns the value of attribute original_filename.



352
353
354
# File 'app/controllers/gluttonberg/admin/asset_library/assets_controller.rb', line 352

def original_filename
  @original_filename
end

#sizeObject

Returns the value of attribute size.



352
353
354
# File 'app/controllers/gluttonberg/admin/asset_library/assets_controller.rb', line 352

def size
  @size
end

Class Method Details

.find_content_type(filename) ⇒ Object



365
366
367
368
369
370
371
# File 'app/controllers/gluttonberg/admin/asset_library/assets_controller.rb', line 365

def self.find_content_type(filename)
  begin
   MIME::Types.type_for(filename).first.content_type
  rescue
    ""
  end
end

.init(filename, entry) ⇒ Object



354
355
356
357
358
359
360
# File 'app/controllers/gluttonberg/admin/asset_library/assets_controller.rb', line 354

def self.init(filename , entry)
  file = MyFile.new(filename)
  file.original_filename = filename
  file.content_type = find_content_type(filename)
  file.size = entry.size
  file
end

Instance Method Details

#tempfileObject



362
363
364
# File 'app/controllers/gluttonberg/admin/asset_library/assets_controller.rb', line 362

def tempfile
  self
end