Sha256: d27e2a0b4e37ef01bf3923df6d4b63a7a1c8e56f2d4ac63a111599e7613ba51f

Contents?: true

Size: 563 Bytes

Versions: 6

Compression:

Stored size: 563 Bytes

Contents

module Kosher
  class Seller < Struct.new(:merchant_id, :average_rating)
    class << self
      attr_accessor :blacklist

      def build(doc)
        merchant_id    = doc['MerchantId']
        average_rating = doc['AverageFeedbackRating'].to_f

        new(merchant_id, average_rating)
      end
    end

    def blacklist
      self.class.blacklist
    end

    def blacklisted?
      blacklist.include? merchant_id rescue false
    end

    def kosher?
      return false if blacklisted?

      average_rating == 0.0 || average_rating > 4.7
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kosher-0.1.5 lib/kosher/seller.rb
kosher-0.1.4 lib/kosher/seller.rb
kosher-0.1.3 lib/kosher/seller.rb
kosher-0.1.2 lib/kosher/seller.rb
kosher-0.1.1 lib/kosher/seller.rb
kosher-0.1.0 lib/kosher/seller.rb