Sha256: 08416bbd9c3b81737b97925bffcd465478456c1f846aa67c4072c02018c867e7

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module Nanoc::Int
  # @api private
  class OutdatednessStore < ::Nanoc::Int::Store
    include Nanoc::Int::ContractsSupport

    contract C::KeywordArgs[site: C::Maybe[Nanoc::Int::Site]] => C::Any
    def initialize(site: nil)
      super(Nanoc::Int::Store.tmp_path_for(site: site, store_name: 'outdatedness'), 1)

      @outdated_refs = Set.new
    end

    contract Nanoc::Int::ItemRep => C::Bool
    def include?(obj)
      @outdated_refs.include?(obj.reference)
    end

    contract Nanoc::Int::ItemRep => self
    def add(obj)
      @outdated_refs << obj.reference
      self
    end

    contract Nanoc::Int::ItemRep => self
    def remove(obj)
      @outdated_refs.delete(obj.reference)
      self
    end

    contract C::None => C::Bool
    def empty?
      @outdated_refs.empty?
    end

    contract C::None => self
    def clear
      @outdated_refs = Set.new
      self
    end

    protected

    def data
      @outdated_refs
    end

    def data=(new_data)
      @outdated_refs = Set.new(new_data)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nanoc-4.8.12 lib/nanoc/base/repos/outdatedness_store.rb
nanoc-4.8.11 lib/nanoc/base/repos/outdatedness_store.rb
nanoc-4.8.10 lib/nanoc/base/repos/outdatedness_store.rb