Sha256: d0ca5bedfe15fb8f5418c9d6c1778f7f61d4c30d2f87421f7d54ee572adfe4c2

Contents?: true

Size: 576 Bytes

Versions: 7

Compression:

Stored size: 576 Bytes

Contents

module CouchPotato
  Database.class_eval do
    def load_document_with_class_reloading(id)
      begin
        load_document_without_class_reloading id
      rescue ArgumentError => e
        if(name = e.message.scan(/(can't find const|undefined class\/module) ([\w\:]+)/).first[1])
          eval name
          retry
        else
          raise e
        end
      end
    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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
couch_potato-0.2.27 rails/reload_classes.rb
couch_potato-0.2.26 rails/reload_classes.rb
couch_potato-0.2.25 rails/reload_classes.rb
couch_potato-0.2.24 rails/reload_classes.rb
couch_potato-0.2.23 rails/reload_classes.rb
couch_potato-0.2.22 rails/reload_classes.rb
couch_potato-0.2.21 rails/reload_classes.rb