Class: Mongoid::AttachmentsUploaderHelper::FileHelper
- Inherits:
-
Object
- Object
- Mongoid::AttachmentsUploaderHelper::FileHelper
- Defined in:
- lib/kit/models/attachments_uploader_helper.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
- #file? ⇒ Boolean
-
#initialize(object) ⇒ FileHelper
constructor
A new instance of FileHelper.
- #name ⇒ Object
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
#object ⇒ Object (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
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 |
#name ⇒ Object
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 |