Class: HasHelpers::SearchPresenter::DetailListPresenter::DetailItemPresenter
- Inherits:
-
BasePresenter
- Object
- BasePresenter
- HasHelpers::SearchPresenter::DetailListPresenter::DetailItemPresenter
- Defined in:
- app/presenters/has_helpers/search_presenter.rb
Instance Attribute Summary collapse
-
#abbreviation ⇒ Object
Returns the value of attribute abbreviation.
-
#format ⇒ Object
writeonly
String value to be displayed.
- #icons ⇒ Object
- #meta ⇒ Object
-
#name ⇒ Object
writeonly
String value to be displayed.
-
#skin ⇒ Object
Returns the value of attribute skin.
-
#value ⇒ Object
Returns One of the following in the given order: - The string explicitly set using the :name option.
Attributes inherited from BasePresenter
Instance Method Summary collapse
Methods inherited from BasePresenter
#==, #error_on, #initialize, wrap, wrap_with_options
Methods included from Attributes
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
#abbreviation ⇒ Object
Returns the value of attribute abbreviation.
6 7 8 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 6 def abbreviation @abbreviation end |
#format=(value) ⇒ Object (writeonly)
String value to be displayed
7 8 9 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 7 def format=(value) @format = value end |
#icons ⇒ Object
32 33 34 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 32 def icons [*(@icons || @icon)].lazy.map(&:to_icon) end |
#meta ⇒ Object
36 37 38 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 36 def @meta ||= {} end |
#name=(value) ⇒ Object (writeonly)
String value to be displayed
7 8 9 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 7 def name=(value) @name = value end |
#skin ⇒ Object
Returns the value of attribute skin.
6 7 8 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 6 def skin @skin end |
#value ⇒ Object
Returns
One of the following in the given order:
- The string explicitly set using the :name option.
- The value passed as the :value option.
- The name attribute of the wrapped object, if the object is present and responds to name (i.e. ActiveRecord models).
- The wrapped_object itself, which is useful for just passing a string instead of a Hash arguments.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 20 def value unformatted_value = @name || @value || (wrapped_object && wrapped_object.try(:name)) || wrapped_object transformed_value = case @format when "date" then Chronic.parse(unformatted_value) else unformatted_value end @format ? ::HasHelpers::Helpers::Application.send("format_#{ @format }", transformed_value) : transformed_value end |
Instance Method Details
#to_h ⇒ Object
40 41 42 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 40 def to_h { name: value } end |