Class: Katello::ProductContentPresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Katello::ProductContentPresenter
- Defined in:
- app/presenters/katello/product_content_presenter.rb
Instance Attribute Summary collapse
-
#overrides ⇒ Object
Returns the value of attribute overrides.
-
#product_content ⇒ Object
Returns the value of attribute product_content.
Instance Method Summary collapse
- #content_overrides ⇒ Object
- #enabled_content_override ⇒ Object
-
#initialize(product_content, overrides) ⇒ ProductContentPresenter
constructor
A new instance of ProductContentPresenter.
- #override ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize(product_content, overrides) ⇒ ProductContentPresenter
Returns a new instance of ProductContentPresenter.
5 6 7 8 9 |
# File 'app/presenters/katello/product_content_presenter.rb', line 5 def initialize(product_content, overrides) @product_content = product_content @overrides = overrides super(@product_content) end |
Instance Attribute Details
#overrides ⇒ Object
Returns the value of attribute overrides.
3 4 5 |
# File 'app/presenters/katello/product_content_presenter.rb', line 3 def overrides @overrides end |
#product_content ⇒ Object
Returns the value of attribute product_content.
3 4 5 |
# File 'app/presenters/katello/product_content_presenter.rb', line 3 def product_content @product_content end |
Instance Method Details
#content_overrides ⇒ Object
22 23 24 25 |
# File 'app/presenters/katello/product_content_presenter.rb', line 22 def content_overrides return [] if overrides.blank? overrides.select { |pc| pc.content_label == content.label } end |
#enabled_content_override ⇒ Object
17 18 19 20 |
# File 'app/presenters/katello/product_content_presenter.rb', line 17 def enabled_content_override return nil if overrides.blank? overrides.find { |pc| pc.content_label == content.label && pc.name == "enabled" } end |
#override ⇒ Object
11 12 13 14 15 |
# File 'app/presenters/katello/product_content_presenter.rb', line 11 def override return 'default' if overrides.blank? override = overrides.find { |pc| pc.content_label == content.label && pc.name == "enabled" } override.nil? ? 'default' : override.value end |
#status ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/presenters/katello/product_content_presenter.rb', line 27 def status overidden_value = enabled_content_override&.computed_value if overidden_value.nil? { status: enabled ? "enabled" : "disabled", overridden: false } else { status: overidden_value ? "enabled" : "disabled", overridden: true } end end |