Class: Integral::Image
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Integral::Image
- Defined in:
- app/models/integral/image.rb
Overview
Represents an image 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 ⇒ Object
- .integral_icon ⇒ Object
-
.listable_options ⇒ Hash
Listable options to be used within a RecordSelector widget.
Instance Method Summary collapse
-
#dimensions ⇒ String
Represents the dimensions of the original image.
-
#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.
78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/models/integral/image.rb', line 78 def self. { icon: integral_icon, order: .dig(:backend_create_menu, :order), label: model_name.human, url: url_helpers.send("new_backend_img_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 ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/models/integral/image.rb', line 61 def self. { icon: integral_icon, order: .dig(:backend_main_menu, :order), label: model_name.human.pluralize, url: url_helpers.send("backend_img_index_url"), authorize_class: self, authorize_action: :index, list_items: [ { label: I18n.t('integral.navigation.dashboard'), url: url_helpers.send("backend_img_index_url"), authorize_class: self, authorize_action: :index }, { label: I18n.t('integral.actions.create'), url: url_helpers.send("new_backend_img_url"), authorize_class: self, authorize_action: :new }, { label: I18n.t('integral.navigation.listing'), url: url_helpers.send("list_backend_img_index_url"), authorize_class: self, authorize_action: :list }, ] } end |
.integral_icon ⇒ Object
57 58 59 |
# File 'app/models/integral/image.rb', line 57 def self.integral_icon 'image' end |
.listable_options ⇒ Hash
Returns listable options to be used within a RecordSelector widget.
49 50 51 52 53 54 55 |
# File 'app/models/integral/image.rb', line 49 def self. { record_title: I18n.t('integral.backend.record_selector.images.record'), selector_path: Engine.routes.url_helpers.list_backend_images_path, selector_title: I18n.t('integral.backend.record_selector.images.title') } end |
Instance Method Details
#dimensions ⇒ String
Returns represents the dimensions of the original image.
33 34 35 |
# File 'app/models/integral/image.rb', line 33 def dimensions "#{width}x#{height}px" if width && height end |
#to_list_item ⇒ Hash
Returns the instance as a list item.
38 39 40 41 42 43 44 45 46 |
# File 'app/models/integral/image.rb', line 38 def to_list_item { id: id, title: title, subtitle: description, description: description, image: file } end |