lib/rdf/model/statement.rb in rdf-0.1.1 vs lib/rdf/model/statement.rb in rdf-0.1.2
- old
+ new
@@ -47,13 +47,14 @@
# @param [URI] predicate
# @param [Value] object
# @param [Hash{Symbol => Object}] options
# @option options [Resource] :context (nil)
def initialize(subject = nil, predicate = nil, object = nil, options = {})
+ options = options.dup unless options.empty?
case subject
when Hash
- options = subject
+ options = subject.dup
subject = options.delete(:subject)
predicate = options.delete(:predicate)
object = options.delete(:object)
initialize(subject, predicate, object, options)
else
@@ -141,11 +142,11 @@
##
# @param [Statement] other
# @return [Boolean]
def eql?(other)
- other.is_a?(Statement) && self == other
+ other.is_a?(Statement) && self == other && self.context == other.context
end
##
# @param [Object] other
# @return [Boolean]
@@ -155,10 +156,11 @@
##
# @param [Statement] other
# @return [Boolean]
def ===(other)
+ return false if has_context? && context != other.context
return false if has_subject? && subject != other.subject
return false if has_predicate? && predicate != other.predicate
return false if has_object? && object != other.object
return true
end
@@ -226,10 +228,13 @@
when RDF::Literal then object.to_s
when RDF::Node then object.to_s
when RDF::URI then "<#{object}>"
else object.inspect
end
- buffer << " ."
+ buffer << case context
+ when nil then " ."
+ else " <#{context}> ."
+ end
buffer.string
end
end
end
end