Class: Refinery::Resource
- Inherits:
-
Core::BaseModel
- Object
- ActiveRecord::Base
- Core::BaseModel
- Refinery::Resource
- Extended by:
- Mobility
- Includes:
- Refinery::Resources::Validators
- Defined in:
- resources/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
- #cached_mime_type ⇒ Object
-
#title ⇒ Object
Returns a titleized version of the filename my_file.pdf returns My File.
-
#type_of_content ⇒ Object
used for searching.
- #update_index ⇒ Object
Methods inherited from Core::BaseModel
Class Method Details
.create_resources(params) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'resources/app/models/refinery/resource.rb', line 53 def create_resources(params) resources = [] if params.present? && params[:file].is_a?(Array) params[:file].each do |resource| resources << create({ file: resource }.merge(params.except(:file).to_h)) end else resources << create(params) end resources end |
Instance Method Details
#cached_mime_type ⇒ Object
25 26 27 |
# File 'resources/app/models/refinery/resource.rb', line 25 def cached_mime_type @cached_mime_type ||= mime_type end |
#title ⇒ Object
Returns a titleized version of the filename my_file.pdf returns My File
36 37 38 |
# File 'resources/app/models/refinery/resource.rb', line 36 def title resource_title.presence || CGI.unescape(file_name.to_s).gsub(/\.\w+$/, '').titleize end |
#type_of_content ⇒ Object
used for searching
30 31 32 |
# File 'resources/app/models/refinery/resource.rb', line 30 def type_of_content cached_mime_type.split('/').join(' ') end |
#update_index ⇒ Object
40 41 42 43 44 45 |
# File 'resources/app/models/refinery/resource.rb', line 40 def update_index return if aai_config.disable_auto_indexing copy = dup.tap { |r| r.file_uid = r.file_uid_was } self.class.index_remove(copy) self.class.index_add(self) end |