Class: Katello::ComponentViewPresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Katello::ComponentViewPresenter
- Defined in:
- app/services/katello/component_view_presenter.rb
Instance Attribute Summary collapse
-
#component_view ⇒ Object
Returns the value of attribute component_view.
-
#view ⇒ Object
Returns the value of attribute view.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(composite_cv, component_content_view = nil, content_view_component = nil) ⇒ ComponentViewPresenter
constructor
A new instance of ComponentViewPresenter.
Constructor Details
#initialize(composite_cv, component_content_view = nil, content_view_component = nil) ⇒ ComponentViewPresenter
Returns a new instance of ComponentViewPresenter.
5 6 7 8 9 10 |
# File 'app/services/katello/component_view_presenter.rb', line 5 def initialize(composite_cv, component_content_view = nil, content_view_component = nil) @view = component_content_view cv_component_record = content_view_component || Katello::ContentViewComponent.where(composite_content_view_id: composite_cv.id, content_view_id: @view.id).first @component_view = cv_component_record || Katello::ContentViewComponent.new(composite_content_view_id: composite_cv.id, content_view_id: @view.id, latest: true) super(@component_view) end |
Instance Attribute Details
#component_view ⇒ Object
Returns the value of attribute component_view.
3 4 5 |
# File 'app/services/katello/component_view_presenter.rb', line 3 def component_view @component_view end |
#view ⇒ Object
Returns the value of attribute view.
3 4 5 |
# File 'app/services/katello/component_view_presenter.rb', line 3 def view @view end |
Class Method Details
.component_presenter(composite_cv, status, views:) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/services/katello/component_view_presenter.rb', line 12 def self.component_presenter(composite_cv, status, views:) case status when 'All' views.map { |component_content_view| ComponentViewPresenter.new(composite_cv, component_content_view) } when 'Added' added_cvs = views.map { |component_content_view| Katello::ContentViewComponent.where(composite_content_view_id: composite_cv.id, content_view_id: component_content_view.id).first } added_cvs.compact.map { |content_view| ComponentViewPresenter.new(composite_cv, nil, content_view) } when 'Not added' not_added_cvs = views.reject { |component_content_view| Katello::ContentViewComponent.where(composite_content_view_id: composite_cv.id, content_view_id: component_content_view.id).first } not_added_cvs.map { |component_content_view| ComponentViewPresenter.new(composite_cv, nil, Katello::ContentViewComponent.where(composite_content_view_id: composite_cv.id, content_view_id: component_content_view.id, latest: true).new) } else views.map { |component_content_view| ComponentViewPresenter.new(composite_cv, component_content_view) } end end |