Class: Nanoc::Int::Document Private

Inherits:
Object
  • Object
show all
Includes:
ContractsSupport
Defined in:
lib/nanoc/base/entities/document.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Direct Known Subclasses

Item, Layout

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ContractsSupport

included

Constructor Details

#initialize(content, attributes, identifier, checksum_data: nil) ⇒ Document

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Document.

Parameters:



34
35
36
37
38
39
# File 'lib/nanoc/base/entities/document.rb', line 34

def initialize(content, attributes, identifier, checksum_data: nil)
  @content = Nanoc::Int::Content.create(content)
  @attributes = Nanoc::Int::LazyValue.new(attributes).map(&:__nanoc_symbolize_keys_recursively)
  @identifier = Nanoc::Identifier.from(identifier)
  @checksum_data = checksum_data
end

Instance Attribute Details

#checksum_dataString?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



19
20
21
# File 'lib/nanoc/base/entities/document.rb', line 19

def checksum_data
  @checksum_data
end

#contentNanoc::Int::Content (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



8
9
10
# File 'lib/nanoc/base/entities/document.rb', line 8

def content
  @content
end

#identifierNanoc::Identifier

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



16
17
18
# File 'lib/nanoc/base/entities/document.rb', line 16

def identifier
  @identifier
end

Instance Method Details

#==(other) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



69
70
71
# File 'lib/nanoc/base/entities/document.rb', line 69

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

#attributesHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



11
12
13
# File 'lib/nanoc/base/entities/document.rb', line 11

def attributes
  @attributes.value
end

#eql?(other) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


74
75
76
# File 'lib/nanoc/base/entities/document.rb', line 74

def eql?(other)
  other.is_a?(self.class) && identifier == other.identifier
end

#freezevoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.



43
44
45
46
47
48
# File 'lib/nanoc/base/entities/document.rb', line 43

def freeze
  super
  @content.freeze
  @attributes.freeze
  self
end

#hashObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



64
65
66
# File 'lib/nanoc/base/entities/document.rb', line 64

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

#inspectObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



59
60
61
# File 'lib/nanoc/base/entities/document.rb', line 59

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

#referenceObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method is abstract.

Returns Unique reference to this object.

Returns:

  • Unique reference to this object

Raises:

  • (NotImplementedError)


54
55
56
# File 'lib/nanoc/base/entities/document.rb', line 54

def reference
  raise NotImplementedError
end