Class: HasHelpers::SearchPresenter::ResultPresenter
- Inherits:
-
BasePresenter
- Object
- BasePresenter
- HasHelpers::SearchPresenter::ResultPresenter
- Defined in:
- app/presenters/has_helpers/search_presenter.rb
Instance Attribute Summary collapse
-
#abbreviation ⇒ Object
Returns the value of attribute abbreviation.
-
#details ⇒ Object
writeonly
Sets the attribute details.
- #icon ⇒ Object
-
#id ⇒ Object
Returns the value of attribute id.
-
#is_heading ⇒ Object
Returns the value of attribute is_heading.
-
#klass ⇒ Object
Returns the value of attribute klass.
- #klass_name ⇒ Object
-
#name ⇒ Object
Returns the value of attribute name.
-
#photo_info ⇒ Object
Returns the value of attribute photo_info.
-
#screen ⇒ Object
Returns the value of attribute screen.
-
#search_submit ⇒ Object
Returns the value of attribute search_submit.
- #service ⇒ Object
-
#show_type ⇒ Object
Returns the value of attribute show_type.
-
#sub_item ⇒ Object
Returns the value of attribute sub_item.
-
#sub_item_type ⇒ Object
Returns the value of attribute sub_item_type.
- #type ⇒ Object
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.
90 91 92 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 90 def abbreviation @abbreviation end |
#details=(value) ⇒ Object (writeonly)
Sets the attribute details
92 93 94 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 92 def details=(value) @details = value end |
#icon ⇒ Object
101 102 103 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 101 def icon !photo_service && @icon # && @icon.to_icon # only return icon name end |
#id ⇒ Object
Returns the value of attribute id.
90 91 92 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 90 def id @id end |
#is_heading ⇒ Object
Returns the value of attribute is_heading.
90 91 92 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 90 def is_heading @is_heading end |
#klass ⇒ Object
Returns the value of attribute klass.
90 91 92 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 90 def klass @klass end |
#klass_name ⇒ Object
122 123 124 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 122 def klass_name @klass_name || klass.name end |
#name ⇒ Object
Returns the value of attribute name.
90 91 92 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 90 def name @name end |
#photo_info ⇒ Object
Returns the value of attribute photo_info.
90 91 92 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 90 def photo_info @photo_info end |
#screen ⇒ Object
Returns the value of attribute screen.
90 91 92 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 90 def screen @screen end |
#search_submit ⇒ Object
Returns the value of attribute search_submit.
90 91 92 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 90 def search_submit @search_submit end |
#service ⇒ Object
117 118 119 120 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 117 def service @service ||= "/#{ klass_name.demodulize.tableize }/#{ id }".to_service @service.respond_to?(:call) ? @service.call : @service end |
#show_type ⇒ Object
Returns the value of attribute show_type.
90 91 92 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 90 def show_type @show_type end |
#sub_item ⇒ Object
Returns the value of attribute sub_item.
90 91 92 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 90 def sub_item @sub_item end |
#sub_item_type ⇒ Object
Returns the value of attribute sub_item_type.
90 91 92 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 90 def sub_item_type @sub_item_type end |
#type ⇒ Object
130 131 132 133 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 130 def type return unless show_type && @type @type.demodulize.titleize end |
Instance Method Details
#base_type ⇒ Object
126 127 128 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 126 def base_type @type&.safe_constantize&.base_class&.name end |
#detail_list ⇒ Object
94 95 96 97 98 99 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 94 def detail_list details = @details || {} = { wrapped_object: details } [:skin] = "sub-item-only" if @details.blank? || (@details && @details.all? { |_k, v| v.blank? }) DetailListPresenter.new() end |
#photo_service ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 105 def photo_service if @photo_service_memoized @photo_service else @photo_service_memoized = true @photo_service ||= ::HasHelpers::Helpers::Application.photo_info_service( @photo_info, application: ->(resource_typish, *_) { %w[users organizations].include?(resource_typish) ? "hqadmin" : ::HasHelpers::Application.project } ) end end |
#to_h ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'app/presenters/has_helpers/search_presenter.rb', line 135 def to_h { image_url: photo_service&.url, icon: icon, abbreviation: abbreviation, label: name, value: id, sub_item: sub_item, details: detail_list.to_h, type: type, baseType: base_type&.demodulize, screen: screen, showType: show_type } end |