Sha256: 41c21bb05100a99a0dc3da06e6fccc89d7ede4de269a3e67169b30dcf068ff9f

Contents?: true

Size: 1.12 KB

Versions: 54

Compression:

Stored size: 1.12 KB

Contents

module Katello
  class ProductContentPresenter < SimpleDelegator
    attr_accessor :product_content, :overrides

    def initialize(product_content, overrides)
      @product_content = product_content
      @overrides = overrides
      super(@product_content)
    end

    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

    def enabled_content_override
      return nil if overrides.blank?
      overrides.find { |pc| pc.content_label == content.label && pc.name == "enabled" }
    end

    def content_overrides
      return [] if overrides.blank?
      overrides.select { |pc| pc.content_label == content.label }
    end

    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
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
katello-4.14.3 app/presenters/katello/product_content_presenter.rb
katello-4.14.2 app/presenters/katello/product_content_presenter.rb
katello-4.14.1 app/presenters/katello/product_content_presenter.rb
katello-4.14.0 app/presenters/katello/product_content_presenter.rb
katello-4.14.0.rc3 app/presenters/katello/product_content_presenter.rb
katello-4.14.0.rc2 app/presenters/katello/product_content_presenter.rb
katello-4.14.0.rc1.1 app/presenters/katello/product_content_presenter.rb
katello-4.14.0.rc1 app/presenters/katello/product_content_presenter.rb
katello-4.13.1 app/presenters/katello/product_content_presenter.rb
katello-4.13.0 app/presenters/katello/product_content_presenter.rb
katello-4.12.1 app/presenters/katello/product_content_presenter.rb
katello-4.13.0.rc1 app/presenters/katello/product_content_presenter.rb
katello-4.12.0 app/presenters/katello/product_content_presenter.rb
katello-4.12.0.rc3 app/presenters/katello/product_content_presenter.rb
katello-4.12.0.rc2 app/presenters/katello/product_content_presenter.rb
katello-4.12.0.rc1 app/presenters/katello/product_content_presenter.rb
katello-4.11.1 app/presenters/katello/product_content_presenter.rb
katello-4.11.0 app/presenters/katello/product_content_presenter.rb
katello-4.11.0.rc2 app/presenters/katello/product_content_presenter.rb
katello-4.11.0.rc1 app/presenters/katello/product_content_presenter.rb