Class: HasHelpers::ItemPresenter

Inherits:
BasePresenter show all
Defined in:
app/presenters/has_helpers/item_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

#data=(value) ⇒ Object (writeonly)

Sets the attribute data

Parameters:

  • value

    the value to set the attribute data to.



6
7
8
# File 'app/presenters/has_helpers/item_presenter.rb', line 6

def data=(value)
  @data = value
end

#detailsObject



10
11
12
# File 'app/presenters/has_helpers/item_presenter.rb', line 10

def details
  Array[*@details]
end

#emphasizedObject

Returns the value of attribute emphasized.



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

def emphasized
  @emphasized
end

#highlightObject

Returns the value of attribute highlight.



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

def highlight
  @highlight
end

#iconObject



30
31
32
# File 'app/presenters/has_helpers/item_presenter.rb', line 30

def icon
  @icon && @icon.to_icon
end

#image_serviceObject



18
19
20
# File 'app/presenters/has_helpers/item_presenter.rb', line 18

def image_service
  @image_service && @image_service.to_service
end

#is_headingObject

Returns the value of attribute is_heading.



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

def is_heading
  @is_heading
end

#itemsObject



34
35
36
# File 'app/presenters/has_helpers/item_presenter.rb', line 34

def items
  ::HasHelpers::ItemPresenter.new(items: @items) if @items
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#selectedObject

Returns the value of attribute selected.



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

def selected
  @selected
end

#serviceObject



14
15
16
# File 'app/presenters/has_helpers/item_presenter.rb', line 14

def service
  @service && @service.to_service
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

#tagObject

Returns the value of attribute tag.



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

def tag
  @tag
end

#titleObject



38
39
40
41
42
43
# File 'app/presenters/has_helpers/item_presenter.rb', line 38

def title
  case @title
  when TrueClass then name
  else @title
  end
end

Instance Method Details

#attributesObject



45
46
47
48
49
50
51
# File 'app/presenters/has_helpers/item_presenter.rb', line 45

def attributes
  (@data || {}).tap do |data_hash|
    data_hash.keys.each do |k|
      data_hash["data-#{k}"] = data_hash.delete(k)
    end
  end
end

#cache_keyObject



22
23
24
# File 'app/presenters/has_helpers/item_presenter.rb', line 22

def cache_key
  nil
end

#itemObject



26
27
28
# File 'app/presenters/has_helpers/item_presenter.rb', line 26

def item
  self
end