Sha256: 7fc213a4a62f12e8a3ee238f70a4997f4a798b9aa8d7263a958ef1f6ef3ca702

Contents?: true

Size: 392 Bytes

Versions: 5

Compression:

Stored size: 392 Bytes

Contents

module Workarea
  decorate Catalog::Product, with: :browse_option do
    decorated do
      field :browse_option, type: String
    end

    def browses_by_option?
      browse_option.present?
    end

    def browse_options
      variants
        .select(&:active?)
        .map { |v| v.fetch_detail(browse_option) }
        .flatten
        .reject(&:blank?)
        .uniq
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
workarea-browse_option-2.2.0 app/models/workarea/catalog/product.decorator
workarea-browse_option-2.1.9 app/models/workarea/catalog/product.decorator
workarea-browse_option-2.1.8 app/models/workarea/catalog/product.decorator
workarea-browse_option-2.1.7 app/models/workarea/catalog/product.decorator
workarea-browse_option-2.1.6 app/models/workarea/catalog/product.decorator