class Nanoc::Core::Document
Attributes
attributes_checksum_data[RW]
@return [String, nil]
checksum_data[RW]
@return [String, nil]
content[R]
@return [Nanoc::Core::Content]
content_checksum_data[RW]
@return [String, nil]
identifier[R]
@return [Nanoc::Core::Identifier]
Public Class Methods
new(content, attributes, identifier, checksum_data: nil, content_checksum_data: nil, attributes_checksum_data: nil)
click to toggle source
@param [String, Nanoc::Core::Content] content
@param [Hash, Proc] attributes
@param [String, Nanoc::Core::Identifier] identifier
@param [String, nil] checksum_data
@param [String, nil] content_checksum_data
@param [String, nil] attributes_checksum_data
# 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
Public Instance Methods
==(other)
click to toggle source
# File lib/nanoc/core/document.rb, line 114 def ==(other) other.respond_to?(:identifier) && identifier == other.identifier end
attributes()
click to toggle source
@return [Hash]
# File lib/nanoc/core/document.rb, line 55 def attributes @attributes.value end
content=(new_content)
click to toggle source
# File lib/nanoc/core/document.rb, line 89 def content=(new_content) @content = new_content @checksum_data = nil @content_checksum_data = nil end
eql?(other)
click to toggle source
# File lib/nanoc/core/document.rb, line 119 def eql?(other) other.is_a?(self.class) && identifier == other.identifier end
freeze()
click to toggle source
@return [void]
Calls superclass method
# File lib/nanoc/core/document.rb, line 61 def freeze super @content.freeze @attributes.freeze self end
hash()
click to toggle source
# File lib/nanoc/core/document.rb, line 109 def hash self.class.hash ^ identifier.hash end
identifier=(new_identifier)
click to toggle source
# File lib/nanoc/core/document.rb, line 84 def identifier=(new_identifier) @identifier = Nanoc::Core::Identifier.from(new_identifier) end
inspect()
click to toggle source
# File lib/nanoc/core/document.rb, line 104 def inspect "<#{self.class} identifier=\"#{identifier}\">" end
reference()
click to toggle source
@abstract
@return Unique reference to this object
# File lib/nanoc/core/document.rb, line 79 def reference raise NotImplementedError end
set_attribute(key, value)
click to toggle source
# 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)
click to toggle source
# File lib/nanoc/core/document.rb, line 69 def with_identifier_prefix(prefix) other = dup other.identifier = @identifier.prefix(prefix) other end