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 +1 -0
- data/README.markdown +5 -3
- data/lib/serialize_with_options/railtie.rb +9 -0
- data/lib/serialize_with_options/version.rb +1 -1
- data/lib/serialize_with_options.rb +4 -2
- data/serialize_with_options.gemspec +1 -1
- data/test/test_helper.rb +1 -1
- metadata +11 -13
- data/init.rb +0 -1
data/.gitignore
CHANGED
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
|
-
|
71
|
+
Simply add "`serialize_with_options`" to your Gemfile:
|
72
72
|
|
73
|
-
|
73
|
+
gem "serialize_with_options"
|
74
|
+
|
75
|
+
And run "`bundle install`"
|
74
76
|
|
75
77
|
* * *
|
76
78
|
|
77
|
-
Copyright (c) 2009-
|
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,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
|
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
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.
|
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-
|
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: &
|
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: *
|
24
|
+
version_requirements: *70169796710200
|
26
25
|
- !ruby/object:Gem::Dependency
|
27
26
|
name: shoulda
|
28
|
-
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: *
|
35
|
+
version_requirements: *70169796709760
|
37
36
|
- !ruby/object:Gem::Dependency
|
38
37
|
name: sqlite3
|
39
|
-
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: *
|
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.
|
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)
|