Sha256: c8bdf81bd528b6f43d49314767b120270e68d53cff27faec8a7326d0c60b9820

Contents?: true

Size: 1.33 KB

Versions: 7

Compression:

Stored size: 1.33 KB

Contents

module Nanoc::Int
  # @api private
  class Item < ::Nanoc::Int::Document
    # @return [Array<Nanoc::Int::ItemRep>] This item’s list of item reps
    attr_reader :reps

    # @return [Nanoc::Int::Item, nil] The parent item of this item. This can be
    #   nil even for non-root items.
    attr_accessor :parent

    # @return [Array<Nanoc::Int::Item>] The child items of this item
    attr_accessor :children

    # @see Document#initialize
    def initialize(content, attributes, identifier)
      super

      @parent = nil
      @children = []
      @reps = []
      @forced_outdated_status = ForcedOutdatedStatus.new
    end

    def freeze
      super
      @children.freeze
    end

    # Returns an object that can be used for uniquely identifying objects.
    #
    # @api private
    #
    # @return [Object] An unique reference to this object
    def reference
      [:item, identifier.to_s]
    end

    # Hack to allow a frozen item to still have modifiable frozen status.
    #
    # FIXME: Remove this.
    class ForcedOutdatedStatus
      attr_accessor :bool

      def initialize
        @bool = false
      end

      def freeze
      end
    end

    # @api private
    def forced_outdated=(bool)
      @forced_outdated_status.bool = bool
    end

    # @api private
    def forced_outdated?
      @forced_outdated_status.bool
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
nanoc-4.0.2 lib/nanoc/base/source_data/item.rb
nanoc-4.0.1 lib/nanoc/base/source_data/item.rb
nanoc-4.0.0 lib/nanoc/base/source_data/item.rb
nanoc-4.0.0rc3 lib/nanoc/base/source_data/item.rb
nanoc-4.0.0rc2 lib/nanoc/base/source_data/item.rb
nanoc-4.0.0rc1 lib/nanoc/base/source_data/item.rb
nanoc-4.0.0b4 lib/nanoc/base/source_data/item.rb