Permalink
Browse files

Make parser a class variable

  • Loading branch information...
1 parent 72a21f2 commit 6804ffc8680ed6466c66f2472f5e016c412c2c24 @sferik sferik committed Apr 16, 2012
Showing with 3 additions and 4 deletions.
  1. +3 −4 lib/multi_xml.rb
View
@@ -57,9 +57,8 @@ class ParseError < StandardError; end
class << self
# Get the current parser class.
def parser
- return @parser if @parser
+ return @@parser if defined?(@@parser)
self.parser = self.default_parser
- @parser
end
# The default parser based on what you currently
@@ -92,9 +91,9 @@ def parser=(new_parser)
case new_parser
when String, Symbol
require "multi_xml/parsers/#{new_parser.to_s.downcase}"
- @parser = MultiXml::Parsers.const_get("#{new_parser.to_s.split('_').map{|s| s.capitalize}.join('')}")
+ @@parser = MultiXml::Parsers.const_get("#{new_parser.to_s.split('_').map{|s| s.capitalize}.join('')}")
when Class, Module
- @parser = new_parser
+ @@parser = new_parser
else
raise "Did not recognize your parser specification. Please specify either a symbol or a class."
end

0 comments on commit 6804ffc

Please sign in to comment.