Class: Integral::Storage::File
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Integral::Storage::File
- Defined in:
- app/models/integral/storage/file.rb
Overview
Represents a file uploaded by a user
Class Method Summary collapse
-
.integral_backend_create_menu_item ⇒ Hash
Hash representing the class, used to render within the create menu.
-
.integral_backend_main_menu_item ⇒ Hash
Hash representing the class, used to render within the main menu.
Instance Method Summary collapse
- #eagerly_process_image_variants ⇒ Object
-
#to_list_item ⇒ Hash
The instance as a list item.
Methods inherited from ApplicationRecord
Class Method Details
.integral_backend_create_menu_item ⇒ Hash
Returns hash representing the class, used to render within the create menu.
50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/models/integral/storage/file.rb', line 50 def self. { icon: integral_icon, order: .dig(:backend_create_menu, :order), label: I18n.t('integral.actions.upload'), url: url_helpers.send("new_backend_#{model_name.singular_route_key}_url"), # authorize: proc { policy(self).index? }, can't use this as self is in wrong context authorize_class: self, authorize_action: :new, } end |
.integral_backend_main_menu_item ⇒ Hash
Returns hash representing the class, used to render within the main menu.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/models/integral/storage/file.rb', line 32 def self. { icon: integral_icon, order: .dig(:backend_main_menu, :order), label: I18n.t('integral.navigation.storage_files'), url: url_helpers.send("backend_#{model_name.route_key}_url"), # authorize: proc { policy(self).index? }, can't use this as self is in wrong context authorize_class: self, authorize_action: :index, list_items: [ { label: I18n.t('integral.navigation.dashboard'), url: url_helpers.send("backend_#{model_name.route_key}_url"), authorize_class: self, authorize_action: :index }, { label: I18n.t('integral.actions.upload'), url: url_helpers.send("new_backend_#{model_name.singular_route_key}_url"), authorize_class: self, authorize_action: :new }, { label: I18n.t('integral.navigation.list'), url: url_helpers.send("list_backend_#{model_name.route_key}_url"), authorize_class: self, authorize_action: :list }, ] } end |
Instance Method Details
#eagerly_process_image_variants ⇒ Object
73 74 75 76 77 |
# File 'app/models/integral/storage/file.rb', line 73 def eagerly_process_image_variants if .attached? && .image? ProcessImageVariantsJob.perform_later(self) end end |
#to_list_item ⇒ Hash
Returns the instance as a list item.
63 64 65 66 67 68 69 70 71 |
# File 'app/models/integral/storage/file.rb', line 63 def to_list_item { id: id, title: title, subtitle: .byte_size, description: description, image: } end |