Sha256: 488f1b3b4423e495f241cae79d187166f922d58d6ab99544a43d12ed5f5a75b7

Contents?: true

Size: 482 Bytes

Versions: 2

Compression:

Stored size: 482 Bytes

Contents

module SmartAleck
  class FindingViablePeers
    attr_reader :categories

    def initialize(categories = [])
      @categories = categories
    end

    def viable_peers
      return SmartAleck.category_model.with_entries if categories.empty?
      categories.
        map(&:entries).
        flatten.
        uniq.
        select {|entry| (categories.map(&:id) - entry.category_ids).empty?}.
        map(&:categories).
        flatten.
        uniq - categories
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
smart_aleck-0.1.0 lib/smart_aleck/finding_viable_peers.rb
smart_aleck-0.0.1 lib/smart_aleck/finding_viable_peers.rb