Class: Refinery::Resource
- Inherits:
-
Core::BaseModel
- Object
- Core::BaseModel
- Refinery::Resource
- Includes:
- Refinery::Resources::Validators
- Defined in:
- app/models/refinery/resource.rb
Class Method Summary collapse
- .create_resources(params) ⇒ Object
-
.per_page(dialog = false) ⇒ Object
How many resources per page should be displayed?.
Instance Method Summary collapse
-
#title ⇒ Object
Returns a titleized version of the filename my_file.pdf returns My File.
-
#type_of_content ⇒ Object
used for searching.
Class Method Details
.create_resources(params) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/models/refinery/resource.rb', line 35 def create_resources(params) resources = [] unless params.present? and params[:file].is_a?(Array) resources << create(params) else params[:file].each do |resource| resources << create({:file => resource}.merge(params.except(:file))) end end resources end |
.per_page(dialog = false) ⇒ Object
How many resources per page should be displayed?
31 32 33 |
# File 'app/models/refinery/resource.rb', line 31 def per_page(dialog = false) dialog ? Resources.pages_per_dialog : Resources.pages_per_admin_index end |
Instance Method Details
#title ⇒ Object
Returns a titleized version of the filename my_file.pdf returns My File
25 26 27 |
# File 'app/models/refinery/resource.rb', line 25 def title CGI::unescape(file_name.to_s).gsub(/\.\w+$/, '').titleize end |
#type_of_content ⇒ Object
used for searching
19 20 21 |
# File 'app/models/refinery/resource.rb', line 19 def type_of_content mime_type.split("/").join(" ") end |