Class: Lolita::Configuration::Tab::Files
- Inherits:
-
Base
- Object
- Base
- Lolita::Configuration::Tab::Files
- Defined in:
- lib/lolita-file-upload/configuration/tab/files.rb
Overview
FileTab extend Lolita default tab with new lolita accessors.
-
extensions
- Array of extension white list -
maxfilesize
- uploaded file maximums size
Instance Attribute Summary collapse
-
#association(name = nil) ⇒ Object
readonly
Returns the value of attribute association.
-
#association_type ⇒ Object
readonly
Returns the value of attribute association_type.
-
#editable_fields(*names) ⇒ Object
readonly
Returns the value of attribute editable_fields.
-
#uploader(name = nil) ⇒ Object
readonly
Returns the value of attribute uploader.
Instance Method Summary collapse
- #association_dbi ⇒ Object
- #extension_white_list ⇒ Object
-
#filters(title = nil, extensions = nil) ⇒ Object
NOTE: Filters only limit frontend, backend limit is set in Uploader.
-
#initialize(dbi, *args, &block) ⇒ Files
constructor
As any other Lolita::Configuration::Tab this should receive dbi object.
Constructor Details
#initialize(dbi, *args, &block) ⇒ Files
As any other Lolita::Configuration::Tab this should receive dbi object. Additional args that may represent methods, for details see Lolita::Configuration::Tab. And block.
15 16 17 18 19 20 21 22 |
# File 'lib/lolita-file-upload/configuration/tab/files.rb', line 15 def initialize(dbi,*args,&block) @type=:files @filters=[] @dbi=dbi @editable_fields=[] set_default_association super end |
Instance Attribute Details
#association(name = nil) ⇒ Object (readonly)
Returns the value of attribute association.
10 11 12 |
# File 'lib/lolita-file-upload/configuration/tab/files.rb', line 10 def association @association end |
#association_type ⇒ Object (readonly)
Returns the value of attribute association_type.
10 11 12 |
# File 'lib/lolita-file-upload/configuration/tab/files.rb', line 10 def association_type @association_type end |
#editable_fields(*names) ⇒ Object (readonly)
Returns the value of attribute editable_fields.
10 11 12 |
# File 'lib/lolita-file-upload/configuration/tab/files.rb', line 10 def editable_fields @editable_fields end |
#uploader(name = nil) ⇒ Object (readonly)
Returns the value of attribute uploader.
10 11 12 |
# File 'lib/lolita-file-upload/configuration/tab/files.rb', line 10 def uploader @uploader end |
Instance Method Details
#association_dbi ⇒ Object
57 58 59 |
# File 'lib/lolita-file-upload/configuration/tab/files.rb', line 57 def association_dbi Lolita::DBI::Base.new self.association.klass end |
#extension_white_list ⇒ Object
66 67 68 |
# File 'lib/lolita-file-upload/configuration/tab/files.rb', line 66 def extension_white_list self.association.klass.uploaders[self.uploader].new.extension_white_list end |
#filters(title = nil, extensions = nil) ⇒ Object
NOTE: Filters only limit frontend, backend limit is set in Uploader
Add another filter or just title for uploader’s extension_white_list
Example
# using in lolita configuration definition
lolita do
tab(:file) do
title "Pictures"
filters "Images", "png,jpg"
# OR
filters "Pictures"
end
end
38 39 40 41 |
# File 'lib/lolita-file-upload/configuration/tab/files.rb', line 38 def filters(title=nil, extensions=nil) @filters << {:title => title, :extensions => extensions || self.extension_white_list} if title (@filters.empty? && self.extension_white_list) ? [{:title => self.title, :extensions => self.extension_white_list}] : @filters end |