to_json_fix 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +32 -10
- data/VERSION +1 -1
- data/lib/to_json_fix.rb +8 -0
- data/test/helper.rb +13 -1
- data/test/test_to_json_fix.rb +6 -0
- data/to_json_fix.gemspec +1 -1
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -1,16 +1,38 @@
|
|
1
1
|
= to_json_fix
|
2
2
|
|
3
|
-
|
3
|
+
class Time
|
4
|
+
def to_json(*)
|
5
|
+
super nil
|
6
|
+
end
|
7
|
+
end
|
4
8
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
class Date
|
10
|
+
def to_json(*)
|
11
|
+
super nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Symbol
|
16
|
+
def to_json(*)
|
17
|
+
to_s.to_json
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
if defined?(ActiveSupport::HashWithIndifferentAccess)
|
22
|
+
class ActiveSupport::HashWithIndifferentAccess
|
23
|
+
def to_json(*)
|
24
|
+
to_hash.to_json
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
if defined?(ActiveRecord::Base)
|
30
|
+
class ActiveRecord::Base
|
31
|
+
def to_json(*args)
|
32
|
+
super nil
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
14
36
|
|
15
37
|
== Copyright
|
16
38
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/lib/to_json_fix.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -4,7 +4,19 @@ require 'shoulda'
|
|
4
4
|
|
5
5
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
6
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
7
|
-
|
7
|
+
|
8
|
+
# do this first so the HashWithIndifferentAccess is defined
|
9
|
+
require 'active_support/hash_with_indifferent_access'
|
10
|
+
|
11
|
+
# do this first so ActiveRecord::Base is defined
|
12
|
+
module ActiveRecord
|
13
|
+
class Base
|
14
|
+
# more or less what ActiveRecord wants to_json to be before the json gem interferes
|
15
|
+
def to_json(options = nil)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
8
20
|
require 'to_json_fix'
|
9
21
|
|
10
22
|
class Test::Unit::TestCase
|
data/test/test_to_json_fix.rb
CHANGED
@@ -20,4 +20,10 @@ class TestToJsonFix < Test::Unit::TestCase
|
|
20
20
|
should "to_json a HashWithIndifferentAccess" do
|
21
21
|
assert_equal "{\"a\":\"b\"}", ActiveSupport::HashWithIndifferentAccess.new(:a => :b).to_json
|
22
22
|
end
|
23
|
+
|
24
|
+
should "to_json an ActiveRecord::Base" do
|
25
|
+
assert_nothing_raised do
|
26
|
+
{ :a => ActiveRecord::Base.new }.to_json
|
27
|
+
end
|
28
|
+
end
|
23
29
|
end
|
data/to_json_fix.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: to_json_fix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Seamus Abshere
|