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 CHANGED
@@ -1,16 +1,38 @@
1
1
  = to_json_fix
2
2
 
3
- Description goes here.
3
+ class Time
4
+ def to_json(*)
5
+ super nil
6
+ end
7
+ end
4
8
 
5
- == Note on Patches/Pull Requests
6
-
7
- * Fork the project.
8
- * Make your feature addition or bug fix.
9
- * Add tests for it. This is important so I don't break it in a
10
- future version unintentionally.
11
- * Commit, do not mess with rakefile, version, or history.
12
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
- * Send me a pull request. Bonus points for topic branches.
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
1
+ 0.0.2
data/lib/to_json_fix.rb CHANGED
@@ -31,3 +31,11 @@ if defined?(ActiveSupport::HashWithIndifferentAccess)
31
31
  end
32
32
  end
33
33
  end
34
+
35
+ if defined?(ActiveRecord::Base)
36
+ class ActiveRecord::Base
37
+ def to_json(*args)
38
+ super nil
39
+ end
40
+ end
41
+ end
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
- require 'active_support/hash_with_indifferent_access' # do this first so the HashWithIndifferentAccess fix is added
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
@@ -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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{to_json_fix}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Seamus Abshere"]
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: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Seamus Abshere