Class: HasHelpers::ItemsPresenter

Inherits:
BasePresenter show all
Defined in:
app/presenters/has_helpers/items_presenter.rb

Overview

typed: true frozen_string_literal: true

Instance Attribute Summary collapse

Attributes inherited from BasePresenter

#errors, #wrapped_object

Instance Method Summary collapse

Methods inherited from BasePresenter

#==, #error_on, #initialize, wrap, wrap_with_options

Methods included from Attributes

included

Constructor Details

This class inherits a constructor from HasHelpers::BasePresenter

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class HasHelpers::BasePresenter

Instance Attribute Details

#attributesObject



19
20
21
# File 'app/presenters/has_helpers/items_presenter.rb', line 19

def attributes
  @attributes || []
end

#items(i = @items) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'app/presenters/has_helpers/items_presenter.rb', line 8

def items(i = @items)
  @memoized_items ||= i.map do |item| # rubocop:disable Naming/MemoizedInstanceVariableName
    case item
    when ::HasHelpers::CacheableItem
      item
    else
      ::HasHelpers::ItemPresenter.new(item)
    end
  end
end

#skinObject

Returns the value of attribute skin.



5
6
7
# File 'app/presenters/has_helpers/items_presenter.rb', line 5

def skin
  @skin
end

Instance Method Details

#cache_keyObject



23
24
25
26
27
28
29
30
31
32
# File 'app/presenters/has_helpers/items_presenter.rb', line 23

def cache_key
  @cache_key ||= if @cache_key_is_memoized
    @cache_key_memoized
  else
    @cache_key_is_memoized = true
    @cache_key_memoized = if (cache_key_items = items.map(&:cache_key)).all?
      Digest::MD5.hexdigest cache_key_items.join
    end
  end
end