Created
November 22, 2009 23:09
-
-
Save kirel/240778 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/rails/reload_classes.rb b/rails/reload_classes.rb | |
| index ff881bf..ca34ebe 100644 | |
| --- a/rails/reload_classes.rb | |
| +++ b/rails/reload_classes.rb | |
| @@ -1,37 +1,10 @@ | |
| -module CouchPotato | |
| - module Persistence | |
| - | |
| - def self.persistent_classes #:nodoc: | |
| - @persistent_classes ||= [] | |
| - end | |
| - | |
| - def self.reload_persistent_classes #:nodoc: | |
| - persistent_classes.each do |clazz| | |
| - eval clazz.name | |
| - end | |
| - end | |
| - | |
| - | |
| - def self.included_with_class_reloading(base) #:nodoc: | |
| - persistent_classes << base | |
| - included_without_class_reloading(base) | |
| - end | |
| - | |
| - class << self | |
| - alias_method :included_without_class_reloading, :included | |
| - alias_method :included, :included_with_class_reloading | |
| - end | |
| +def JSON.parse(source, opts = {}) | |
| + JSON.parser.new(source, opts).parse | |
| +rescue ArgumentError => e | |
| + if e.message =~ /(::)?([A-Z][\w]+::)*[A-Z][\w]+\z/ | |
| + eval($&) rescue nil | |
| + retry | |
| + else | |
| + raise | |
| end | |
| - | |
| - Database.class_eval do | |
| - def load_document_with_class_reloading(id) | |
| - Persistence.reload_persistent_classes | |
| - load_document_without_class_reloading id | |
| - end | |
| - | |
| - alias_method :load_document_without_class_reloading, :load_document | |
| - alias_method :load_document, :load_document_with_class_reloading | |
| - alias_method :load, :load_document | |
| - end | |
| -end | |
| - | |
| +end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment