Sha256: 005fb5a241b22de756ef6c4197bcb9e91d30b44ca724dc5cfc16675300cb8a22

Contents?: true

Size: 668 Bytes

Versions: 62

Compression:

Stored size: 668 Bytes

Contents

module Workarea
  module Recommendation
    class Settings
      include ApplicationDocument

      # _id will match the product ID
      field :_id, type: String, default: -> { SecureRandom.hex(5).upcase }
      field :sources, type: Array, default: Workarea.config.product_based_recommendation_default_sources
      field :product_ids, type: Array, default: []
      list_field :product_ids

      validates :sources, presence: true
      before_validation :ensure_sources

      private

      def ensure_sources
        if sources.blank?
          self.sources = Workarea.config.product_based_recommendation_default_sources
        end
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.4.13 app/models/workarea/recommendation/settings.rb
workarea-core-3.4.12 app/models/workarea/recommendation/settings.rb