Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make parser a class variable

  • Loading branch information...
commit 6804ffc8680ed6466c66f2472f5e016c412c2c24 1 parent 72a21f2
@sferik authored
Showing with 3 additions and 4 deletions.
  1. +3 −4 lib/multi_xml.rb
View
7 lib/multi_xml.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.