Sha256: 369e62221564c8b469ff142c6fa2d3c5222b6394ee6b116b69506dd1dd373eac
Contents?: true
Size: 946 Bytes
Versions: 5
Compression:
Stored size: 946 Bytes
Contents
module Workarea class BrowseOptionIds class << self def all_for(product, options = []) return [product.id] unless product.browses_by_option? (Array.wrap(options).presence || product.browse_options).map do |option| build(product.id, option.optionize) end end def for(product, option = nil) return product.id unless product.browses_by_option? if option.present? build(product.id, option.optionize) else all_for(product).first end end def build(product_id, option) [product_id, conjunction, option.optionize].join end def split(browse_option_id) browse_option_id.to_s.split(conjunction) end def extract(browse_option_id) split(browse_option_id).first end def conjunction Workarea.config.browse_option_product_id_conjunction end end end end
Version data entries
5 entries across 5 versions & 1 rubygems