lib/nanoc/base/entities/document.rb in nanoc-4.1.6 vs lib/nanoc/base/entities/document.rb in nanoc-4.2.0b1
- old
+ new
@@ -4,30 +4,38 @@
class Document
# @return [Nanoc::Int::Content]
attr_reader :content
# @return [Hash]
- attr_reader :attributes
+ def attributes
+ @attributes.value
+ end
# @return [Nanoc::Identifier]
attr_accessor :identifier
+ # @return [String, nil]
+ attr_accessor :checksum_data
+
# @param [String, Nanoc::Int::Content] content
#
- # @param [Hash] attributes
+ # @param [Hash, Proc] attributes
#
# @param [String, Nanoc::Identifier] identifier
- def initialize(content, attributes, identifier)
+ #
+ # @param [String, nil] checksum_data Used to determine whether the document has changed
+ def initialize(content, attributes, identifier, checksum_data: nil)
@content = Nanoc::Int::Content.create(content)
- @attributes = attributes.__nanoc_symbolize_keys_recursively
+ @attributes = Nanoc::Int::LazyValue.new(attributes).map(&:__nanoc_symbolize_keys_recursively)
@identifier = Nanoc::Identifier.from(identifier)
+ @checksum_data = checksum_data
end
# @return [void]
def freeze
super
- attributes.__nanoc_freeze_recursively
- content.freeze
+ @content.freeze
+ @attributes.freeze
end
# @abstract
#
# @return Unique reference to this object