Skip to content
Browse files

Restored C-backed JSON serialization

  • Loading branch information...
1 parent bdae831 commit b05c189d16c815f624818fb3b2aecc4fa0656415 @konklone konklone committed Jul 5, 2011
Showing with 17 additions and 0 deletions.
  1. +17 −0 config/environment.rb
View
17 config/environment.rb
@@ -1,6 +1,23 @@
+require 'json/ext'
+
+# hack to stop ActiveSupport from taking away my JSON C extension
+[Object, Array, FalseClass, Float, Hash, Integer, NilClass, String, TrueClass].each do |klass|
+ klass.class_eval do
+ alias_method :to_json_from_gem, :to_json
+ end
+end
+
require 'sinatra'
require 'mongo_mapper'
+# restore the original to_json on core objects (damn you ActiveSupport)
+[Object, Array, FalseClass, Float, Hash, Integer, NilClass, String, TrueClass].each do |klass|
+ klass.class_eval do
+ alias_method :to_json, :to_json_from_gem
+ end
+end
+
+
def config
@config ||= YAML.load_file 'config/config.yml'
end

0 comments on commit b05c189

Please sign in to comment.
Something went wrong with that request. Please try again.