Class: CafeCar::ActiveStorage::AttachmentPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/cafe_car/active_storage/attachment_presenter.rb

Instance Method Summary collapse

Instance Method Details

#blankObject



8
9
10
11
# File 'app/presenters/cafe_car/active_storage/attachment_presenter.rb', line 8

def blank = options[:blank]
# An attachment is its own logo — it renders as its own image. Keep the base
# `logo(*, **, &)` signature so callers (e.g. the grid item's `logo(href:)`)
# don't hit an arity mismatch; the args aren't needed since we return self.

#imageObject



14
15
16
# File 'app/presenters/cafe_car/active_storage/attachment_presenter.rb', line 14

def image
  @template.image_tag url, **options, class: ui.class(:image, size) if url
end

#logoObject

An attachment is its own logo — it renders as its own image. Keep the base logo(*, **, &) signature so callers (e.g. the grid item's logo(href:)) don't hit an arity mismatch; the args aren't needed since we return self.



12
# File 'app/presenters/cafe_car/active_storage/attachment_presenter.rb', line 12

def (*, **, &) = self

#previewObject



18
# File 'app/presenters/cafe_car/active_storage/attachment_presenter.rb', line 18

def preview = image || blank

#urlObject

def url = object.representation(resize_to_limit: [300, 300])&.processed&.url



7
# File 'app/presenters/cafe_car/active_storage/attachment_presenter.rb', line 7

def url = object.try(:url)