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
|
# 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
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
114
115
116
|
# File 'lib/nanoc/core/document.rb', line 114
def ==(other)
other.respond_to?(:identifier) && identifier == other.identifier
end
|
#attributes ⇒ Hash
55
56
57
|
# File 'lib/nanoc/core/document.rb', line 55
def attributes
@attributes.value
end
|
#eql?(other) ⇒ Boolean
119
120
121
|
# File 'lib/nanoc/core/document.rb', line 119
def eql?(other)
other.is_a?(self.class) && identifier == other.identifier
end
|
#freeze ⇒ void
This method returns an undefined value.
61
62
63
64
65
66
|
# File 'lib/nanoc/core/document.rb', line 61
def freeze
super
@content.freeze
@attributes.freeze
self
end
|
#hash ⇒ Object
109
110
111
|
# File 'lib/nanoc/core/document.rb', line 109
def hash
self.class.hash ^ identifier.hash
end
|
#inspect ⇒ Object
104
105
106
|
# File 'lib/nanoc/core/document.rb', line 104
def inspect
"<#{self.class} identifier=\"#{identifier}\">"
end
|
#reference ⇒ Object
Returns Unique reference to this object.
79
80
81
|
# File 'lib/nanoc/core/document.rb', line 79
def reference
raise NotImplementedError
end
|
#set_attribute(key, value) ⇒ Object
96
97
98
99
100
101
|
# File 'lib/nanoc/core/document.rb', line 96
def set_attribute(key, value)
attributes[key] = value
@checksum_data = nil
@attributes_checksum_data = nil
end
|
#with_identifier_prefix(prefix) ⇒ Object
69
70
71
72
73
|
# File 'lib/nanoc/core/document.rb', line 69
def with_identifier_prefix(prefix)
other = dup
other.identifier = @identifier.prefix(prefix)
other
end
|