Sha256: a450a30c8840228442ece3c8e944d6ed0e624a059513b380fdb462088a1fd1ce

Contents?: true

Size: 883 Bytes

Versions: 8

Compression:

Stored size: 883 Bytes

Contents

module Nanoc::Int
  # @api private
  class DependencyTracker
    class Null
      def enter(_obj)
      end

      def exit(_obj)
      end

      def bounce(_obj)
      end
    end

    include Nanoc::Int::ContractsSupport

    def initialize(dependency_store)
      @dependency_store = dependency_store
      @stack = []
    end

    contract C::Or[Nanoc::Int::Item, Nanoc::Int::Layout] => C::Any
    def enter(obj)
      unless @stack.empty?
        Nanoc::Int::NotificationCenter.post(:dependency_created, @stack.last, obj)
        @dependency_store.record_dependency(@stack.last, obj)
      end

      @stack.push(obj)
    end

    contract C::Or[Nanoc::Int::Item, Nanoc::Int::Layout] => C::Any
    def exit(_obj)
      @stack.pop
    end

    contract C::Or[Nanoc::Int::Item, Nanoc::Int::Layout] => C::Any
    def bounce(obj)
      enter(obj)
      exit(obj)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
nanoc-4.3.8 lib/nanoc/base/compilation/dependency_tracker.rb
nanoc-4.3.7 lib/nanoc/base/compilation/dependency_tracker.rb
nanoc-4.3.6 lib/nanoc/base/compilation/dependency_tracker.rb
nanoc-4.3.5 lib/nanoc/base/compilation/dependency_tracker.rb
nanoc-4.3.4 lib/nanoc/base/compilation/dependency_tracker.rb
nanoc-4.3.3 lib/nanoc/base/compilation/dependency_tracker.rb
nanoc-4.3.2 lib/nanoc/base/compilation/dependency_tracker.rb
nanoc-4.3.1 lib/nanoc/base/compilation/dependency_tracker.rb