Class: Mongo::Model::AttachmentsHelper::FileHelper
- Inherits:
-
Object
- Object
- Mongo::Model::AttachmentsHelper::FileHelper
- Defined in:
- lib/kit/models/attachments_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.
4 5 6 |
# File 'lib/kit/models/attachments_helper.rb', line 4 def initialize object @object = object end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
3 4 5 |
# File 'lib/kit/models/attachments_helper.rb', line 3 def object @object end |
Instance Method Details
#file? ⇒ Boolean
8 9 10 |
# File 'lib/kit/models/attachments_helper.rb', line 8 def file? object.is_a?(Hash) or object.is_a?(IO) or object.is_a?(Vfs::File) end |
#name ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/kit/models/attachments_helper.rb', line 12 def name if object.is_a?(Hash) object['filename'] || object[:filename] elsif object.is_a?(IO) File.basename(object.path) elsif object.is_a?(Vfs::File) object.name else object end end |