serialize_with_options 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,3 +3,4 @@ test.db
3
3
  .bundle
4
4
  Gemfile.lock
5
5
  pkg/*
6
+ .rvmrc
data/README.markdown CHANGED
@@ -68,13 +68,15 @@ The `serialize_with_options` class method takes an optional argument for naming
68
68
  Installation
69
69
  ------------
70
70
 
71
- From your app root:
71
+ Simply add "`serialize_with_options`" to your Gemfile:
72
72
 
73
- script/plugin install git://github.com/vigetlabs/serialize_with_options.git
73
+ gem "serialize_with_options"
74
+
75
+ And run "`bundle install`"
74
76
 
75
77
  * * *
76
78
 
77
- Copyright (c) 2009-2010 David Eisinger ([Viget Labs][vgt]), released under the MIT license.
79
+ Copyright (c) 2009-2011 David Eisinger ([Viget Labs][vgt]), released under the MIT license.
78
80
 
79
81
  [ser]: http://api.rubyonrails.org/classes/ActiveRecord/Serialization.html
80
82
  [vgt]: http://www.viget.com/
@@ -0,0 +1,9 @@
1
+ module SerializeWithOptions
2
+ class Railtie < Rails::Railtie
3
+ initializer 'serialize_with_options.extend_active_record', :after => 'active_record.initialize_database' do |app|
4
+ ActiveSupport.on_load(:active_record) do
5
+ self.extend SerializeWithOptions
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module SerializeWithOptions
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -1,3 +1,5 @@
1
+ require 'serialize_with_options/railtie' if defined?(Rails)
2
+
1
3
  module SerializeWithOptions
2
4
  def self.extended(base)
3
5
  base.class_attribute :serialization_conf
@@ -70,9 +72,9 @@ module SerializeWithOptions
70
72
  super(self.class.serialization_options(set).deep_merge(opts))
71
73
  end
72
74
 
73
- def to_json(opts = {})
75
+ def as_json(opts = nil)
74
76
  set, opts = parse_serialization_options(opts)
75
- super(self.class.serialization_options(set).deep_merge(opts))
77
+ super(self.class.serialization_options(set).deep_merge(opts || {}))
76
78
  end
77
79
 
78
80
  private
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_dependency "activerecord", "~> 3"
22
+ s.add_dependency "activerecord", "~> 3.0"
23
23
 
24
24
  s.add_development_dependency "shoulda"
25
25
  s.add_development_dependency "sqlite3"
data/test/test_helper.rb CHANGED
@@ -7,7 +7,7 @@ require 'test/unit'
7
7
  require 'shoulda'
8
8
  require 'json'
9
9
  require 'serialize_with_options'
10
- require 'init'
10
+ ActiveRecord::Base.extend SerializeWithOptions
11
11
 
12
12
  ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
13
13
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serialize_with_options
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,23 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-10 00:00:00.000000000 -04:00
13
- default_executable:
12
+ date: 2011-12-02 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: activerecord
17
- requirement: &2153419300 !ruby/object:Gem::Requirement
16
+ requirement: &70169796710200 !ruby/object:Gem::Requirement
18
17
  none: false
19
18
  requirements:
20
19
  - - ~>
21
20
  - !ruby/object:Gem::Version
22
- version: '3'
21
+ version: '3.0'
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *2153419300
24
+ version_requirements: *70169796710200
26
25
  - !ruby/object:Gem::Dependency
27
26
  name: shoulda
28
- requirement: &2153418880 !ruby/object:Gem::Requirement
27
+ requirement: &70169796709760 !ruby/object:Gem::Requirement
29
28
  none: false
30
29
  requirements:
31
30
  - - ! '>='
@@ -33,10 +32,10 @@ dependencies:
33
32
  version: '0'
34
33
  type: :development
35
34
  prerelease: false
36
- version_requirements: *2153418880
35
+ version_requirements: *70169796709760
37
36
  - !ruby/object:Gem::Dependency
38
37
  name: sqlite3
39
- requirement: &2153418420 !ruby/object:Gem::Requirement
38
+ requirement: &70169796709180 !ruby/object:Gem::Requirement
40
39
  none: false
41
40
  requirements:
42
41
  - - ! '>='
@@ -44,7 +43,7 @@ dependencies:
44
43
  version: '0'
45
44
  type: :development
46
45
  prerelease: false
47
- version_requirements: *2153418420
46
+ version_requirements: *70169796709180
48
47
  description: Simple XML and JSON APIs for your Rails app
49
48
  email:
50
49
  - david.eisinger@gmail.com
@@ -57,13 +56,12 @@ files:
57
56
  - MIT-LICENSE
58
57
  - README.markdown
59
58
  - Rakefile
60
- - init.rb
61
59
  - lib/serialize_with_options.rb
60
+ - lib/serialize_with_options/railtie.rb
62
61
  - lib/serialize_with_options/version.rb
63
62
  - serialize_with_options.gemspec
64
63
  - test/serialize_with_options_test.rb
65
64
  - test/test_helper.rb
66
- has_rdoc: true
67
65
  homepage: http://www.viget.com/extend/simple-apis-using-serializewithoptions
68
66
  licenses: []
69
67
  post_install_message:
@@ -84,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
82
  version: '0'
85
83
  requirements: []
86
84
  rubyforge_project: serialize_with_options
87
- rubygems_version: 1.6.2
85
+ rubygems_version: 1.8.10
88
86
  signing_key:
89
87
  specification_version: 3
90
88
  summary: Simple XML and JSON APIs for your Rails app
data/init.rb DELETED
@@ -1 +0,0 @@
1
- ActiveRecord::Base.extend(SerializeWithOptions)