Class: Refinery::Admin::ListPresenter

Inherits:
GroupPresenter show all
Includes:
ActionView::Helpers::TagHelper, ImagesHelper
Defined in:
app/presenters/refinery/admin/list_presenter.rb

Instance Attribute Summary

Attributes inherited from GroupPresenter

#context, #group_classes, #group_header, #group_headers, #group_tag, #group_wrapper, #groups, #header, #header_tag, #identity_keys

Instance Method Summary collapse

Methods included from ImagesHelper

#locale_text_icon, #other_image_views, #thumbnail_urls

Constructor Details

#initialize(context, header: ->(date) { localized(date) }, groups: ->(records) { context.group_by_date(records, :updated_at) }) ⇒ ListPresenter

Initialize the presenter with a context, a lambda for headers, and a lambda for groups.

Parameters:

  • context (Object)

    An object that provides the necessary methods for grouping and rendering.

  • header (Proc) (defaults to: ->(date) { localized(date) })

    Callable for formatting group headers.

  • groups (Proc) (defaults to: ->(records) { context.group_by_date(records, :updated_at) })

    Callable for grouping records.



12
13
14
15
16
17
18
19
20
# File 'app/presenters/refinery/admin/list_presenter.rb', line 12

def initialize(context,
               header: ->(date) { localized(date) },
               groups: ->(records) { context.group_by_date(records, :updated_at) })
  super(context)
  @identity_keys = [:title, :filename, :alt]
  @group_headers = true
  @header = header
  @groups = groups
end