summaryrefslogtreecommitdiff
path: root/ext/json
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-02 12:28:45 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-02 12:28:45 +0000
commitc20b8f75dd2aa3797e35aa48ec45dc45e487ae7a (patch)
tree1fbdc5657de4ad9dc8613d1a5ddfbca848448426 /ext/json
parent260e8ce6370f2c415d707728ffa249cf92707665 (diff)
* ext/json/lib/json/add/rails.rb: removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/json')
-rw-r--r--ext/json/lib/json/add/rails.rb58
1 files changed, 0 insertions, 58 deletions
diff --git a/ext/json/lib/json/add/rails.rb b/ext/json/lib/json/add/rails.rb
deleted file mode 100644
index 8ce85ef..0000000
--- a/ext/json/lib/json/add/rails.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-# This file contains implementations of rails custom objects for
-# serialisation/deserialisation.
-
-unless Object.const_defined?(:JSON) and ::JSON.const_defined?(:JSON_LOADED) and
- ::JSON::JSON_LOADED
- require 'json'
-end
-
-class Object
- def self.json_create(object)
- obj = new
- for key, value in object
- next if key == JSON.create_id
- instance_variable_set "@#{key}", value
- end
- obj
- end
-
- def to_json(*a)
- result = {
- JSON.create_id => self.class.name
- }
- instance_variables.inject(result) do |r, name|
- r[name[1..-1]] = instance_variable_get name
- r
- end
- result.to_json(*a)
- end
-end
-
-class Symbol
- def to_json(*a)
- to_s.to_json(*a)
- end
-end
-
-module Enumerable
- def to_json(*a)
- to_a.to_json(*a)
- end
-end
-
-# class Regexp
-# def to_json(*)
-# inspect
-# end
-# end
-#
-# The above rails definition has some problems:
-#
-# 1. { 'foo' => /bar/ }.to_json # => "{foo: /bar/}"
-# This isn't valid JSON, because the regular expression syntax is not
-# defined in RFC 4627. (And unquoted strings are disallowed there, too.)
-# Though it is valid Javascript.
-#
-# 2. { 'foo' => /bar/mix }.to_json # => "{foo: /bar/mix}"
-# This isn't even valid Javascript.
-