Class: Nanoc::Core::Document
- Inherits:
-
Object
- Object
- Nanoc::Core::Document
show all
- Includes:
- ContractsSupport
- Defined in:
- lib/nanoc/core/document.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
enabled?, included, setup_once, warn_about_performance
Constructor Details
#initialize(content, attributes, identifier, checksum_data: nil, content_checksum_data: nil, attributes_checksum_data: nil) ⇒ Document
Returns a new instance of Document.
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/nanoc/core/document.rb', line 44
def initialize(
content, attributes, identifier,
checksum_data: nil, content_checksum_data: nil, attributes_checksum_data: nil
)
@content = Nanoc::Core::Content.create(content)
@attributes = Nanoc::Core::LazyValue.new(attributes).map(&:__nanoc_symbolize_keys_recursively)
@identifier = Nanoc::Core::Identifier.from(identifier)
@checksum_data = checksum_data
@content_checksum_data = content_checksum_data
@attributes_checksum_data = attributes_checksum_data
@hash = [self.class, identifier].hash
reference
end
|
Instance Attribute Details
#attributes_checksum_data ⇒ String?
21
22
23
|
# File 'lib/nanoc/core/document.rb', line 21
def attributes_checksum_data
@attributes_checksum_data
end
|
#checksum_data ⇒ String?
15
16
17
|
# File 'lib/nanoc/core/document.rb', line 15
def checksum_data
@checksum_data
end
|
9
10
11
|
# File 'lib/nanoc/core/document.rb', line 9
def content
@content
end
|
#content_checksum_data ⇒ String?
18
19
20
|
# File 'lib/nanoc/core/document.rb', line 18
def content_checksum_data
@content_checksum_data
end
|
12
13
14
|
# File 'lib/nanoc/core/document.rb', line 12
def identifier
@identifier
end
|
Instance Method Details
#==(other) ⇒ Object
121
122
123
|
# File 'lib/nanoc/core/document.rb', line 121
def ==(other)
other.respond_to?(:identifier) && identifier == other.identifier
end
|
#attributes ⇒ Hash
62
63
64
|
# File 'lib/nanoc/core/document.rb', line 62
def attributes
@attributes.value
end
|
#eql?(other) ⇒ Boolean
126
127
128
|
# File 'lib/nanoc/core/document.rb', line 126
def eql?(other)
other.is_a?(self.class) && identifier == other.identifier
end
|
#freeze ⇒ void
This method returns an undefined value.
68
69
70
71
72
73
|
# File 'lib/nanoc/core/document.rb', line 68
def freeze
super
@content.freeze
@attributes.freeze
self
end
|
#hash ⇒ Object
116
117
118
|
# File 'lib/nanoc/core/document.rb', line 116
def hash
@hash
end
|
#inspect ⇒ Object
111
112
113
|
# File 'lib/nanoc/core/document.rb', line 111
def inspect
"<#{self.class} identifier=\"#{identifier}\">"
end
|
#reference ⇒ Object
Returns Unique reference to this object.
86
87
88
|
# File 'lib/nanoc/core/document.rb', line 86
def reference
raise NotImplementedError
end
|
#set_attribute(key, value) ⇒ Object
103
104
105
106
107
108
|
# File 'lib/nanoc/core/document.rb', line 103
def set_attribute(key, value)
attributes[key] = value
@checksum_data = nil
@attributes_checksum_data = nil
end
|
#with_identifier_prefix(prefix) ⇒ Object
76
77
78
79
80
|
# File 'lib/nanoc/core/document.rb', line 76
def with_identifier_prefix(prefix)
other = dup
other.identifier = @identifier.prefix(prefix)
other
end
|