Skip to content

Commit

Permalink
Ensure that subclasses of Reader and Writer return themselves for .fo…
Browse files Browse the repository at this point in the history
…r, in spite of explicit arguments.

This corrects a problem when an explicit writer is used on a file which matches multiple Formats, to ensure that the Reader/Writer doing the call is returned.

Only when the non-subclassed Reader/Writer is used will it perform match based on options.
  • Loading branch information
gkellogg committed Sep 7, 2011
1 parent 0443149 commit 9a4c53d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/rdf/reader.rb
Expand Up @@ -55,6 +55,8 @@ def self.each(&block)
##
# Finds an RDF reader class based on the given criteria.
#
# If the reader class has a defined format, use that.
#
# @overload for(format)
# Finds an RDF reader class based on a symbolic name.
#
Expand All @@ -78,13 +80,13 @@ def self.each(&block)
#
# @return [Class]
def self.for(options = {})
if format = Format.for(options)
if format = self.format || Format.for(options)
format.reader
end
end

##
# Retrieves the RDF serialization format class for this writer class.
# Retrieves the RDF serialization format class for this reader class.
#
# @return [Class]
def self.format(klass = nil)
Expand Down
2 changes: 1 addition & 1 deletion lib/rdf/writer.rb
Expand Up @@ -77,7 +77,7 @@ def self.each(&block)
#
# @return [Class]
def self.for(options = {})
if format = Format.for(options)
if format = self.format || Format.for(options)
format.writer
end
end
Expand Down

0 comments on commit 9a4c53d

Please sign in to comment.