json_serialize 2.2.2 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4ca9bfc2e027de8c3a67c6284ff34b1d56ce1b9ed86cb051ee5d6cbc722d1c9e
4
+ data.tar.gz: 23910e6ab92e3203bf55c7147ee273d5aaabea4360ca347e08a479fa8bfc55a9
5
+ SHA512:
6
+ metadata.gz: 632219ef6d0021e31ab0eb078aeca71f6f20c1abd43f45919b9375f9f8eb3766a4815cde6aef827534b305bfbb0c09514a9e9924e27c7cc0793374c039313a06
7
+ data.tar.gz: f659b50c1800608a2ff6e2a01845666a1a99d12b45942be68ff9afa9edd951a5ef2ab2a94a8a5117f61f147d508aa71dbdea527b05e0d431d8500f7684c999e8
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ > ⚠️ **DEPRECATED:** `json_serialize` is no longer maintained. Modern Rails has
2
+ > native JSON serialization (`serialize :col, JSON` and JSONB columns) that
3
+ > covers the same use cases. The final release is v2.2.3.
4
+
5
+ json_serialize
6
+ ==============
7
+
8
+ **JSON serialization in ActiveRecord**
9
+
10
+ | | |
11
+ |:------------|:--------------------------------|
12
+ | **Author** | Tim Morgan |
13
+ | **Version** | 2.2.2 (May 15, 2013) |
14
+ | **License** | Released under the MIT license. |
15
+
16
+ About
17
+ -----
18
+
19
+ `json_serialize` gives you the ability to JSON-encode data into ActiveRecord
20
+ model fields. JSON is a more compact but less robust serialization than YAML.
21
+ Only hashes, arrays, and primitives can be reliably encoded to database fields;
22
+ other types may not decode properly or at all.
23
+
24
+ Installation and Usage
25
+ ----------------------
26
+
27
+ Firstly, add the gem to your Rails project's `Gemfile`:
28
+
29
+ ```` ruby
30
+ gem 'json_serialize'
31
+ ````
32
+
33
+ Then, include into your model the `JsonSerialize` module, and call the
34
+ `json_serialize` method to indicate which fields should be serialized:
35
+
36
+ ```` ruby
37
+ class MyModel < ActiveRecord::Base
38
+ include JsonSerialize
39
+ json_serialize :favorites, :preferences
40
+ end
41
+ ````
42
+
43
+ More information can be found at the {JsonSerialize::ClassMethods#json_serialize}
44
+ method documentation.
@@ -2,30 +2,40 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: json_serialize 2.2.3 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "json_serialize"
8
- s.version = "2.2.2"
9
+ s.version = "2.2.3"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
12
  s.authors = ["Tim Morgan"]
12
- s.date = "2013-05-16"
13
+ s.date = "2013-12-08"
13
14
  s.description = "Adds to ActiveRecord the ability to JSON-serialize certain fields."
14
15
  s.email = "git@timothymorgan.info"
15
16
  s.extra_rdoc_files = [
16
17
  "LICENSE",
17
- "README.textile"
18
+ "README.md"
18
19
  ]
19
20
  s.files = [
20
21
  "LICENSE",
21
- "README.textile",
22
+ "README.md",
22
23
  "json_serialize.gemspec",
23
24
  "lib/json_serialize.rb"
24
25
  ]
25
26
  s.homepage = "http://github.com/riscfuture/json_serialize"
26
27
  s.require_paths = ["lib"]
27
- s.rubygems_version = "2.0.3"
28
- s.summary = "Adds JSON serialization to ActiveRecord models"
28
+ s.rubygems_version = "2.1.11"
29
+ s.summary = "[DEPRECATED] Adds JSON serialization to ActiveRecord models"
30
+ s.post_install_message = <<~MSG
31
+
32
+ ⚠️ DEPRECATED: json_serialize is no longer maintained.
33
+
34
+ No longer maintained. Modern Rails has native JSON serialization (`serialize :col, JSON` and JSONB columns) that covers the same use cases.
35
+
36
+ This is the final release. No further updates are planned.
37
+
38
+ MSG
29
39
 
30
40
  if s.respond_to? :specification_version then
31
41
  s.specification_version = 4
@@ -1,4 +1,4 @@
1
- # Adds the {#json_serialize} method to @ActiveRecord@ objects.
1
+ # Adds the {ClassMethods#json_serialize} method to `ActiveRecord` objects.
2
2
  #
3
3
  # @example Basic usage
4
4
  # class MyModel < ActiveRecord::Base
@@ -16,15 +16,15 @@ module JsonSerialize
16
16
  # @param [Symbol] field The database field to JSON-serialize.
17
17
  # @param [Hash<Symbol, Object>] fields_with_default_values A map of
18
18
  # additional fields to JSON-serialize, with the default value that
19
- # should be given if the field is @NULL@.
19
+ # should be given if the field is `NULL`.
20
20
 
21
21
  def json_serialize(*fields)
22
- fields_with_defaults = fields.extract_options!
22
+ @fields_with_defaults = fields.extract_options!
23
23
  fields.each do |field|
24
- fields_with_defaults[field] = nil
24
+ @fields_with_defaults[field] = nil
25
25
  end
26
26
 
27
- fields_with_defaults.each do |field, default_value|
27
+ @fields_with_defaults.each do |field, default_value|
28
28
  define_method field do
29
29
  if instance_variable_defined?(field_ivar(field)) then
30
30
  instance_variable_get field_ivar(field)
@@ -36,7 +36,7 @@ module JsonSerialize
36
36
  decoded
37
37
  end
38
38
  end
39
-
39
+
40
40
  define_method :"#{field}=" do |value|
41
41
  write_attribute field, (value.nil? ? nil : ActiveSupport::JSON.encode(value))
42
42
  instance_variable_set field_ivar(field), value
@@ -44,28 +44,29 @@ module JsonSerialize
44
44
  end
45
45
 
46
46
  define_method :serialize_json_values do
47
- fields_with_defaults.keys.each do |field|
47
+ self.class.instance_variable_get(:@fields_with_defaults).keys.each do |field|
48
48
  if instance_variable_defined?(field_ivar(field)) then
49
49
  send :"#{field}=", instance_variable_get(field_ivar(field))
50
50
  end
51
51
  end
52
52
  end
53
-
54
- define_method :reload_with_refresh_json_ivars do |*args|
55
- res = reload_without_refresh_json_ivars *args
56
- fields_with_defaults.keys.each { |field| remove_instance_variable field_ivar(field) if instance_variable_defined?(field_ivar(field)) }
57
- res
58
- end
59
-
60
- define_method :update_with_refresh_json_ivars do |*args|
61
- res = update_without_refresh_json_ivars(*args)
62
- fields_with_defaults.keys.each { |field| remove_instance_variable field_ivar(field) if instance_variable_defined?(field_ivar(field)) }
63
- res
64
- end
65
-
53
+
66
54
  before_validation :serialize_json_values
67
- alias_method_chain :reload, :refresh_json_ivars
68
- alias_method_chain :update, :refresh_json_ivars
55
+ prepend WithRefreshJSONIvars
56
+ end
57
+ end
58
+
59
+ module WithRefreshJSONIvars
60
+ def reload(*args)
61
+ result = super
62
+ self.class.instance_variable_get(:@fields_with_defaults).keys.each { |field| remove_instance_variable field_ivar(field) if instance_variable_defined?(field_ivar(field)) }
63
+ result
64
+ end
65
+
66
+ def update
67
+ result = super
68
+ self.class.instance_variable_defined(:@fields_with_defaults).keys.each { |field| remove_instance_variable field_ivar(field) if instance_variable_defined?(field_ivar(field)) }
69
+ result
69
70
  end
70
71
  end
71
72
 
metadata CHANGED
@@ -1,126 +1,110 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_serialize
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
5
- prerelease:
4
+ version: 2.2.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tim Morgan
9
- autorequire:
10
8
  bindir: bin
11
9
  cert_chain: []
12
- date: 2013-05-16 00:00:00.000000000 Z
10
+ date: 2013-12-08 00:00:00.000000000 Z
13
11
  dependencies:
14
12
  - !ruby/object:Gem::Dependency
15
13
  name: activerecord
16
14
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
15
  requirements:
19
- - - ! '>='
16
+ - - ">="
20
17
  - !ruby/object:Gem::Version
21
18
  version: '3.0'
22
19
  type: :runtime
23
20
  prerelease: false
24
21
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
22
  requirements:
27
- - - ! '>='
23
+ - - ">="
28
24
  - !ruby/object:Gem::Version
29
25
  version: '3.0'
30
26
  - !ruby/object:Gem::Dependency
31
27
  name: activesupport
32
28
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
29
  requirements:
35
- - - ! '>='
30
+ - - ">="
36
31
  - !ruby/object:Gem::Version
37
32
  version: '3.0'
38
33
  type: :runtime
39
34
  prerelease: false
40
35
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
36
  requirements:
43
- - - ! '>='
37
+ - - ">="
44
38
  - !ruby/object:Gem::Version
45
39
  version: '3.0'
46
40
  - !ruby/object:Gem::Dependency
47
41
  name: jeweler
48
42
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
43
  requirements:
51
- - - ! '>='
44
+ - - ">="
52
45
  - !ruby/object:Gem::Version
53
46
  version: '0'
54
47
  type: :development
55
48
  prerelease: false
56
49
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
50
  requirements:
59
- - - ! '>='
51
+ - - ">="
60
52
  - !ruby/object:Gem::Version
61
53
  version: '0'
62
54
  - !ruby/object:Gem::Dependency
63
55
  name: yard
64
56
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
57
  requirements:
67
- - - ! '>='
58
+ - - ">="
68
59
  - !ruby/object:Gem::Version
69
60
  version: '0'
70
61
  type: :development
71
62
  prerelease: false
72
63
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
64
  requirements:
75
- - - ! '>='
65
+ - - ">="
76
66
  - !ruby/object:Gem::Version
77
67
  version: '0'
78
68
  - !ruby/object:Gem::Dependency
79
69
  name: RedCloth
80
70
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
71
  requirements:
83
- - - ! '>='
72
+ - - ">="
84
73
  - !ruby/object:Gem::Version
85
74
  version: '0'
86
75
  type: :development
87
76
  prerelease: false
88
77
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
78
  requirements:
91
- - - ! '>='
79
+ - - ">="
92
80
  - !ruby/object:Gem::Version
93
81
  version: '0'
94
82
  - !ruby/object:Gem::Dependency
95
83
  name: rspec
96
84
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
85
  requirements:
99
- - - ! '>='
86
+ - - ">="
100
87
  - !ruby/object:Gem::Version
101
88
  version: '0'
102
89
  type: :development
103
90
  prerelease: false
104
91
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
92
  requirements:
107
- - - ! '>='
93
+ - - ">="
108
94
  - !ruby/object:Gem::Version
109
95
  version: '0'
110
96
  - !ruby/object:Gem::Dependency
111
97
  name: sqlite3
112
98
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
99
  requirements:
115
- - - ! '>='
100
+ - - ">="
116
101
  - !ruby/object:Gem::Version
117
102
  version: '0'
118
103
  type: :development
119
104
  prerelease: false
120
105
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
106
  requirements:
123
- - - ! '>='
107
+ - - ">="
124
108
  - !ruby/object:Gem::Version
125
109
  version: '0'
126
110
  description: Adds to ActiveRecord the ability to JSON-serialize certain fields.
@@ -129,37 +113,39 @@ executables: []
129
113
  extensions: []
130
114
  extra_rdoc_files:
131
115
  - LICENSE
132
- - README.textile
116
+ - README.md
133
117
  files:
134
118
  - LICENSE
135
- - README.textile
119
+ - README.md
136
120
  - json_serialize.gemspec
137
121
  - lib/json_serialize.rb
138
122
  homepage: http://github.com/riscfuture/json_serialize
139
123
  licenses: []
140
- post_install_message:
124
+ metadata: {}
125
+ post_install_message: |2+
126
+
127
+ ⚠️ DEPRECATED: json_serialize is no longer maintained.
128
+
129
+ No longer maintained. Modern Rails has native JSON serialization (`serialize :col, JSON` and JSONB columns) that covers the same use cases.
130
+
131
+ This is the final release. No further updates are planned.
132
+
141
133
  rdoc_options: []
142
134
  require_paths:
143
135
  - lib
144
136
  required_ruby_version: !ruby/object:Gem::Requirement
145
- none: false
146
137
  requirements:
147
- - - ! '>='
138
+ - - ">="
148
139
  - !ruby/object:Gem::Version
149
140
  version: '0'
150
- segments:
151
- - 0
152
- hash: -1176193426724439302
153
141
  required_rubygems_version: !ruby/object:Gem::Requirement
154
- none: false
155
142
  requirements:
156
- - - ! '>='
143
+ - - ">="
157
144
  - !ruby/object:Gem::Version
158
145
  version: '0'
159
146
  requirements: []
160
- rubyforge_project:
161
- rubygems_version: 1.8.25
162
- signing_key:
163
- specification_version: 3
164
- summary: Adds JSON serialization to ActiveRecord models
147
+ rubygems_version: 4.0.11
148
+ specification_version: 4
149
+ summary: "[DEPRECATED] Adds JSON serialization to ActiveRecord models"
165
150
  test_files: []
151
+ ...
data/README.textile DELETED
@@ -1,33 +0,0 @@
1
- h1. json_serialize -- JSON serialization in ActiveRecord
2
-
3
- | *Author* | Tim Morgan |
4
- | *Version* | 2.2.2 (May 15, 2013) |
5
- | *License* | Released under the MIT license. |
6
-
7
- h2. About
8
-
9
- @json_serialize@ gives you the ability to JSON-encode data into ActiveRecord
10
- model fields. JSON is a more compact but less robust serialization than YAML.
11
- Only hashes, arrays, and primitives can be reliably encoded to database fields;
12
- other types may not decode properly or at all.
13
-
14
- h2. Installation and Usage
15
-
16
- Firstly, add the gem to your Rails project's @Gemfile@:
17
-
18
- <pre><code>
19
- gem 'json_serialize'
20
- </code></pre>
21
-
22
- Then, include into your model the @JsonSerialize@ module, and call the
23
- @json_serialize@ method to indicate which fields should be serialized:
24
-
25
- <pre><code>
26
- class MyModel < ActiveRecord::Base
27
- include JsonSerialize
28
- json_serialize :favorites, :preferences
29
- end
30
- </code></pre>
31
-
32
- More information can be found at the {JsonSerialize#json_serialize} method
33
- documentation.