Class: Mongoid::AttachmentsUploaderHelper::FileHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/kit/models/attachments_uploader_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ FileHelper

Returns a new instance of FileHelper.



6
7
8
# File 'lib/kit/models/attachments_uploader_helper.rb', line 6

def initialize object
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



5
6
7
# File 'lib/kit/models/attachments_uploader_helper.rb', line 5

def object
  @object
end

Instance Method Details

#file?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/kit/models/attachments_uploader_helper.rb', line 10

def file?
  object.is_a?(Hash) or object.is_a?(IO)
end

#nameObject



14
15
16
17
18
19
20
21
22
# File 'lib/kit/models/attachments_uploader_helper.rb', line 14

def name
  if object.is_a?(Hash)
    object['filename'] || object[:filename]
  elsif object.is_a?(IO)
    File.basename(object.path)
  else
    object
  end
end