document: throw ArgumentError if compared to non-doc

This commit is contained in:
Parker Moore 2015-12-22 21:34:24 -05:00
parent 532bb9e9cb
commit 233589e150
1 changed files with 1 additions and 1 deletions

View File

@ -353,7 +353,7 @@ module Jekyll
# Returns -1, 0, +1 or nil depending on whether this doc's path is less than, # Returns -1, 0, +1 or nil depending on whether this doc's path is less than,
# equal or greater than the other doc's path. See String#<=> for more details. # equal or greater than the other doc's path. See String#<=> for more details.
def <=>(other) def <=>(other)
return nil if !other.respond_to?(:data) return ArgumentError.new("document cannot be compared against #{other}") unless other.respond_to?(:data)
cmp = data['date'] <=> other.data['date'] cmp = data['date'] <=> other.data['date']
cmp = path <=> other.path if cmp == 0 cmp = path <=> other.path if cmp == 0
cmp cmp