Sha256: 9b87d5404e40564baf41efa9845c27084967809fb2920311a3f55dab8aa4cae4

Contents?: true

Size: 477 Bytes

Versions: 54

Compression:

Stored size: 477 Bytes

Contents

module Nanoc::Int
  # Stores item reps (in memory).
  #
  # @api private
  class ItemRepRepo
    include Enumerable

    def initialize
      @reps = []
      @reps_by_item = {}
    end

    def <<(rep)
      @reps << rep

      @reps_by_item[rep.item] ||= []
      @reps_by_item[rep.item] << rep
    end

    def to_a
      @reps
    end

    def each(&block)
      @reps.each(&block)
      self
    end

    def [](item)
      @reps_by_item.fetch(item, [])
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
nanoc-4.7.9 lib/nanoc/base/repos/item_rep_repo.rb
nanoc-4.7.8 lib/nanoc/base/repos/item_rep_repo.rb
nanoc-4.7.7 lib/nanoc/base/repos/item_rep_repo.rb
nanoc-4.7.6 lib/nanoc/base/repos/item_rep_repo.rb
nanoc-4.7.5 lib/nanoc/base/repos/item_rep_repo.rb
nanoc-4.7.4 lib/nanoc/base/repos/item_rep_repo.rb
nanoc-4.7.3 lib/nanoc/base/repos/item_rep_repo.rb
nanoc-4.7.2 lib/nanoc/base/repos/item_rep_repo.rb
nanoc-4.7.1 lib/nanoc/base/repos/item_rep_repo.rb
nanoc-4.7.0 lib/nanoc/base/repos/item_rep_repo.rb
nanoc-4.6.4 lib/nanoc/base/repos/item_rep_repo.rb
nanoc-4.6.3 lib/nanoc/base/repos/item_rep_repo.rb
nanoc-4.6.2 lib/nanoc/base/repos/item_rep_repo.rb
nanoc-4.6.1 lib/nanoc/base/repos/item_rep_repo.rb
nanoc-4.6.0 lib/nanoc/base/repos/item_rep_repo.rb
nanoc-4.5.4 lib/nanoc/base/repos/item_rep_repo.rb
nanoc-4.5.3 lib/nanoc/base/repos/item_rep_repo.rb
nanoc-4.5.2 lib/nanoc/base/repos/item_rep_repo.rb
nanoc-4.5.1 lib/nanoc/base/repos/item_rep_repo.rb
nanoc-4.5.0 lib/nanoc/base/repos/item_rep_repo.rb