lib/nanoc3/base/source_data/layout.rb in nanoc3-3.2.0a4 vs lib/nanoc3/base/source_data/layout.rb in nanoc3-3.2.0b1
- old
+ new
@@ -83,16 +83,43 @@
def inspect
"<#{self.class}:0x#{self.object_id.to_s(16)} identifier=#{self.identifier}>"
end
- # TODO document
+ # @return [String] The checksum for this object. If its contents change,
+ # the checksum will change as well.
def checksum
attributes = @attributes.dup
attributes.delete(:file)
@raw_content.checksum + ',' + attributes.checksum
end
memoize :checksum
+
+ def hash
+ self.class.hash ^ self.identifier.hash
+ end
+
+ def eql?(other)
+ self.class == other.class && self.identifier == other.identifier
+ end
+
+ def ==(other)
+ self.eql?(other)
+ end
+
+ def marshal_dump
+ [
+ @raw_content,
+ @attributes,
+ @identifier
+ ]
+ end
+
+ def marshal_load(source)
+ @raw_content,
+ @attributes,
+ @identifier = *source
+ end
# @deprecated Access the modification time using `layout[:mtime]` instead.
def mtime
self[:mtime]
end