Sha256: e472d085ddc7852f57fd79e55490146dfed2aad9c3eecda334745133fdc1b4f2

Contents?: true

Size: 1.19 KB

Versions: 5

Compression:

Stored size: 1.19 KB

Contents

module Nanoc
  module Int
    # @api private
    class Document
      # @return [Nanoc::Int::Content]
      attr_reader :content

      # @return [Hash]
      attr_reader :attributes

      # @return [Nanoc::Identifier]
      attr_accessor :identifier

      # @param [String, Nanoc::Int::Content] content
      #
      # @param [Hash] attributes
      #
      # @param [String, Nanoc::Identifier] identifier
      def initialize(content, attributes, identifier)
        @content = Nanoc::Int::Content.create(content)
        @attributes = attributes.__nanoc_symbolize_keys_recursively
        @identifier = Nanoc::Identifier.from(identifier)
      end

      # @return [void]
      def freeze
        super
        attributes.__nanoc_freeze_recursively
        content.freeze
      end

      # @abstract
      #
      # @return Unique reference to this object
      def reference
        raise NotImplementedError
      end

      def inspect
        "<#{self.class} identifier=\"#{identifier}\">"
      end

      def hash
        self.class.hash ^ identifier.hash
      end

      def ==(other)
        other.respond_to?(:identifier) && identifier == other.identifier
      end
      alias eql? ==
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nanoc-4.1.6 lib/nanoc/base/entities/document.rb
nanoc-4.1.5 lib/nanoc/base/entities/document.rb
nanoc-4.1.4 lib/nanoc/base/entities/document.rb
nanoc-4.1.3 lib/nanoc/base/entities/document.rb
nanoc-4.1.2 lib/nanoc/base/entities/document.rb