active_model_serializers 0.9.8 → 0.9.11
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 +4 -4
- data/CHANGELOG.md +22 -1
- data/lib/action_controller/serialization.rb +10 -1
- data/lib/action_controller/serialization_test_case.rb +3 -0
- data/lib/active_model/array_serializer.rb +2 -0
- data/lib/active_model/default_serializer.rb +2 -0
- data/lib/active_model/serializable/utils.rb +2 -0
- data/lib/active_model/serializable.rb +3 -1
- data/lib/active_model/serializer/association/has_many.rb +2 -0
- data/lib/active_model/serializer/association/has_one.rb +2 -0
- data/lib/active_model/serializer/association.rb +2 -0
- data/lib/active_model/serializer/config.rb +2 -0
- data/lib/active_model/serializer/generators/resource_override.rb +2 -0
- data/lib/active_model/serializer/generators/serializer/scaffold_controller_generator.rb +2 -0
- data/lib/active_model/serializer/generators/serializer/serializer_generator.rb +2 -0
- data/lib/active_model/serializer/railtie.rb +2 -0
- data/lib/active_model/serializer/version.rb +3 -1
- data/lib/active_model/serializer.rb +23 -7
- data/lib/active_model/serializer_support.rb +2 -0
- data/lib/active_model_serializers.rb +14 -2
- data/test/fixtures/poro.rb +31 -0
- data/test/integration/action_controller/serialization_test.rb +13 -13
- data/test/integration/action_controller/serialization_test_case_test.rb +1 -1
- data/test/test_helper.rb +7 -0
- data/test/tmp/app/controllers/accounts_controller.rb +1 -0
- data/test/tmp/app/helpers/accounts_helper.rb +1 -0
- data/test/tmp/app/serializers/account_serializer.rb +1 -0
- data/test/tmp/config/routes.rb +2 -1
- data/test/unit/active_model/array_serializer/serialization_test.rb +23 -0
- data/test/unit/active_model/serializer/has_many_polymorphic_test.rb +1 -1
- data/test/unit/active_model/serializer/has_one_polymorphic_test.rb +1 -1
- metadata +46 -47
- data/lib/active_model_serializers/model/caching.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1c2dbb7d1b6d7673364e690d624e5a8dffa5fddf2f9ee9d6838ac399ab14a96
|
4
|
+
data.tar.gz: 5fcef7df6ec5deb692b68ffd8198e438b8bf2bafe812d12ace97087f9eb9c3f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 281b4a64ab65e4f2aff6b45a393e684e1d69a5fe203c450268cfc001deb20fce6e1269c9aafd1bf54e847bc5a282cfd28f630cb45096ec750bb531363cd93cbd
|
7
|
+
data.tar.gz: 13cd7cfa482532515a8629c35c4e5c0847b1dd791494025f4d6177e05f45f5845641b8bc04cfb543a503b8767afcb8505fd1c433afc0cd73c5bcd0d9a8066119
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,27 @@
|
|
1
1
|
## 0.09.x
|
2
2
|
|
3
|
-
### [0-9-stable](https://github.com/rails-api/active_model_serializers/compare/v0.9.
|
3
|
+
### [0-9-stable](https://github.com/rails-api/active_model_serializers/compare/v0.9.11...0-9-stable)
|
4
|
+
|
5
|
+
### [v0.9.11 (2024-04-09)](https://github.com/rails-api/active_model_serializers/compare/v0.9.10...v0.9.11)
|
6
|
+
|
7
|
+
v0.9.10 was built with an extra file included and so was yanked.
|
8
|
+
v0.9.11 is the same as v0.9.10 but doesn't have the extra file.
|
9
|
+
|
10
|
+
### [v0.9.10 (2024-04-09)](https://github.com/rails-api/active_model_serializers/compare/v0.9.9...v0.9.10)
|
11
|
+
|
12
|
+
- Fix
|
13
|
+
- [#2464](https://github.com/rails-api/active_model_serializers/pull/2464) Do not load ActionController::TestCase in production (@byroot)
|
14
|
+
- Perf
|
15
|
+
- [#2465](https://github.com/rails-api/active_model_serializers/pull/2465) Make compatible with enable-frozen-string-literal (@byroot)
|
16
|
+
- [#2463](https://github.com/rails-api/active_model_serializers/pull/2463) Shape Friendly ActionController:Serialization (@byroot)
|
17
|
+
- Chore
|
18
|
+
- [#2462](https://github.com/rails-api/active_model_serializers/pull/2462]) Rails 7.1, Ruby 3.3 compat (@byroot)
|
19
|
+
- Test
|
20
|
+
- [#2447](https://github.com/rails-api/active_model_serializers/pull/2447) Configure CI on GitHub actoins (@Physium)
|
21
|
+
|
22
|
+
### [v0.9.9 (2023-05-18)](https://github.com/rails-api/active_model_serializers/compare/v0.9.8...v0.9.8)
|
23
|
+
|
24
|
+
- [#2446](https://github.com/rails-api/active_model_serializers/pull/2446) Fix Ruby > 2.5 constant lookup. (@Physium)
|
4
25
|
|
5
26
|
### [v0.9.8 (2020-12-10)](https://github.com/rails-api/active_model_serializers/compare/v0.9.7...v0.9.8)
|
6
27
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_support/core_ext/class/attribute'
|
2
4
|
|
3
5
|
module ActionController
|
@@ -45,6 +47,12 @@ module ActionController
|
|
45
47
|
end
|
46
48
|
end
|
47
49
|
|
50
|
+
def initialize(*)
|
51
|
+
super
|
52
|
+
@namespace_for_serializer = nil
|
53
|
+
end
|
54
|
+
ruby2_keywords :initialize if respond_to?(:ruby2_keywords, true)
|
55
|
+
|
48
56
|
[:_render_option_json, :_render_with_renderer_json].each do |renderer_method|
|
49
57
|
define_method renderer_method do |resource, options|
|
50
58
|
serializer = build_json_serializer(resource, options)
|
@@ -60,7 +68,8 @@ module ActionController
|
|
60
68
|
private
|
61
69
|
|
62
70
|
def namespace_for_serializer
|
63
|
-
@namespace_for_serializer ||= namespace_for_class(self.class)
|
71
|
+
@namespace_for_serializer ||= namespace_for_class(self.class)
|
72
|
+
@namespace_for_serializer unless @namespace_for_serializer == Object
|
64
73
|
end
|
65
74
|
|
66
75
|
def namespace_for_class(klass)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionController
|
2
4
|
module SerializationAssertions
|
3
5
|
extend ActiveSupport::Concern
|
@@ -24,6 +26,7 @@ module ActionController
|
|
24
26
|
@serializers = Hash.new(0)
|
25
27
|
super
|
26
28
|
end
|
29
|
+
ruby2_keywords :process if respond_to?(:ruby2_keywords, true)
|
27
30
|
|
28
31
|
# Asserts that the request was rendered with the appropriate serializers.
|
29
32
|
#
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_model/serializable/utils'
|
2
4
|
|
3
5
|
module ActiveModel
|
4
6
|
module Serializable
|
5
|
-
INSTRUMENTATION_KEY = '!serialize.active_model_serializers'
|
7
|
+
INSTRUMENTATION_KEY = '!serialize.active_model_serializers'
|
6
8
|
|
7
9
|
def self.included(base)
|
8
10
|
base.extend Utils
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_model/array_serializer'
|
2
4
|
require 'active_model/serializable'
|
3
5
|
require 'active_model/serializer/association'
|
@@ -66,10 +68,14 @@ end
|
|
66
68
|
ArraySerializer
|
67
69
|
end
|
68
70
|
else
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
71
|
+
search_list = build_serializer_class_list(resource, options)
|
72
|
+
result = search_list.map do |klass_name|
|
73
|
+
Serializer.serializers_cache.fetch_or_store(klass_name) do
|
74
|
+
_const_get(klass_name)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
result.find { |serializer| !serializer.nil? }
|
73
79
|
end
|
74
80
|
end
|
75
81
|
|
@@ -118,10 +124,20 @@ end
|
|
118
124
|
attr
|
119
125
|
end
|
120
126
|
|
127
|
+
def build_serializer_class_list(resource, options)
|
128
|
+
list = []
|
129
|
+
list << build_serializer_class(resource, options)
|
130
|
+
list << build_serializer_class(resource, {})
|
131
|
+
list << build_serializer_class(resource.class.name.demodulize, {})
|
132
|
+
end
|
133
|
+
|
121
134
|
def build_serializer_class(resource, options)
|
122
|
-
""
|
123
|
-
|
124
|
-
|
135
|
+
klass_name = +""
|
136
|
+
klass_name << "#{options[:namespace]}::" if options[:namespace]
|
137
|
+
klass_name << options[:prefix].to_s.classify if options[:prefix]
|
138
|
+
if resource.is_a?(String)
|
139
|
+
klass_name << "#{resource}Serializer"
|
140
|
+
else
|
125
141
|
klass_name << "#{resource.class.name}Serializer"
|
126
142
|
end
|
127
143
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_model'
|
2
4
|
require 'active_model/serializer'
|
3
5
|
require 'active_model/serializer_support'
|
@@ -7,12 +9,22 @@ require 'active_model/serializer/railtie' if defined?(Rails)
|
|
7
9
|
begin
|
8
10
|
require 'action_controller'
|
9
11
|
require 'action_controller/serialization'
|
10
|
-
require 'action_controller/serialization_test_case'
|
11
12
|
|
12
13
|
ActiveSupport.on_load(:action_controller) do
|
13
14
|
if ::ActionController::Serialization.enabled
|
14
15
|
ActionController::Base.send(:include, ::ActionController::Serialization)
|
15
|
-
|
16
|
+
|
17
|
+
# action_controller_test_case load hook was added in Rails 5.1
|
18
|
+
# https://github.com/rails/rails/commit/0510208dd1ff23baa619884c0abcae4d141fae53
|
19
|
+
if ActiveSupport::VERSION::STRING < '5.1'
|
20
|
+
require 'action_controller/serialization_test_case'
|
21
|
+
ActionController::TestCase.send(:include, ::ActionController::SerializationAssertions)
|
22
|
+
else
|
23
|
+
ActiveSupport.on_load(:action_controller_test_case) do
|
24
|
+
require 'action_controller/serialization_test_case'
|
25
|
+
ActionController::TestCase.send(:include, ::ActionController::SerializationAssertions)
|
26
|
+
end
|
27
|
+
end
|
16
28
|
end
|
17
29
|
end
|
18
30
|
rescue LoadError
|
data/test/fixtures/poro.rb
CHANGED
@@ -18,6 +18,19 @@ end
|
|
18
18
|
###
|
19
19
|
## Models
|
20
20
|
###
|
21
|
+
|
22
|
+
module TestNamespace2
|
23
|
+
class Test < Model
|
24
|
+
attr_writer :sub_test
|
25
|
+
|
26
|
+
def sub_test
|
27
|
+
@sub_test ||= TestNamespace2::SubTest.new(name: 'N1', description: 'D1')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class SubTest < Model; end
|
32
|
+
end
|
33
|
+
|
21
34
|
class User < Model
|
22
35
|
def profile
|
23
36
|
@profile ||= Profile.new(name: 'N1', description: 'D1')
|
@@ -101,6 +114,24 @@ end
|
|
101
114
|
###
|
102
115
|
## Serializers
|
103
116
|
###
|
117
|
+
|
118
|
+
module TestNamespace2
|
119
|
+
class TestSerializer < ActiveModel::Serializer
|
120
|
+
attributes :name, :email
|
121
|
+
|
122
|
+
has_one :sub_test
|
123
|
+
end
|
124
|
+
|
125
|
+
class SubTestSerializer < ActiveModel::Serializer
|
126
|
+
def description
|
127
|
+
description = object.read_attribute_for_serialization(:description)
|
128
|
+
scope ? "#{description} - #{scope}" : description
|
129
|
+
end
|
130
|
+
|
131
|
+
attributes :name, :description
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
104
135
|
class UserSerializer < ActiveModel::Serializer
|
105
136
|
attributes :name, :email
|
106
137
|
|
@@ -13,7 +13,7 @@ module ActionController
|
|
13
13
|
|
14
14
|
def test_render_using_implicit_serializer
|
15
15
|
get :render_using_implicit_serializer
|
16
|
-
|
16
|
+
assert_includes @response.content_type, 'application/json'
|
17
17
|
assert_equal '{"profile":{"name":"Name 1","description":"Description 1"}}', @response.body
|
18
18
|
end
|
19
19
|
end
|
@@ -35,7 +35,7 @@ module ActionController
|
|
35
35
|
|
36
36
|
def test_render_using_implicit_serializer_and_scope
|
37
37
|
get :render_using_implicit_serializer_and_scope
|
38
|
-
|
38
|
+
assert_includes @response.content_type, 'application/json'
|
39
39
|
assert_equal '{"profile":{"name":"Name 1","description":"Description 1 - current_user"}}', @response.body
|
40
40
|
end
|
41
41
|
end
|
@@ -65,7 +65,7 @@ module ActionController
|
|
65
65
|
|
66
66
|
def test_render_using_scope_set_in_default_serializer_options
|
67
67
|
get :render_using_scope_set_in_default_serializer_options
|
68
|
-
|
68
|
+
assert_includes @response.content_type, 'application/json'
|
69
69
|
assert_equal '{"profile":{"name":"Name 1","description":"Description 1 - current_admin"}}', @response.body
|
70
70
|
end
|
71
71
|
end
|
@@ -91,7 +91,7 @@ module ActionController
|
|
91
91
|
|
92
92
|
def test_render_using_implicit_serializer_and_explicit_scope
|
93
93
|
get :render_using_implicit_serializer_and_explicit_scope
|
94
|
-
|
94
|
+
assert_includes @response.content_type, 'application/json'
|
95
95
|
assert_equal '{"profile":{"name":"Name 1","description":"Description 1 - current_admin"}}', @response.body
|
96
96
|
end
|
97
97
|
end
|
@@ -117,7 +117,7 @@ module ActionController
|
|
117
117
|
|
118
118
|
def test_render_overriding_serialization_scope
|
119
119
|
get :render_overriding_serialization_scope
|
120
|
-
|
120
|
+
assert_includes @response.content_type, 'application/json'
|
121
121
|
assert_equal '{"profile":{"name":"Name 1","description":"Description 1 - current_admin"}}', @response.body
|
122
122
|
end
|
123
123
|
end
|
@@ -141,7 +141,7 @@ module ActionController
|
|
141
141
|
|
142
142
|
def test_render_calling_serialization_scope
|
143
143
|
get :render_calling_serialization_scope
|
144
|
-
|
144
|
+
assert_includes @response.content_type, 'application/json'
|
145
145
|
assert_equal '{"profile":{"name":"Name 1","description":"Description 1 - current_user"}}', @response.body
|
146
146
|
end
|
147
147
|
end
|
@@ -157,7 +157,7 @@ module ActionController
|
|
157
157
|
|
158
158
|
def test_render_using_json_dump
|
159
159
|
get :render_using_json_dump
|
160
|
-
|
160
|
+
assert_includes @response.content_type, 'application/json'
|
161
161
|
assert_equal '{"hello":"world"}', @response.body
|
162
162
|
end
|
163
163
|
end
|
@@ -173,7 +173,7 @@ module ActionController
|
|
173
173
|
|
174
174
|
def test_render_using_rails_behavior
|
175
175
|
get :render_using_rails_behavior
|
176
|
-
|
176
|
+
assert_includes @response.content_type, 'application/json'
|
177
177
|
assert_equal '[{"attributes":{"name":"Name 1","description":"Description 1","comments":"Comments 1"}}]', @response.body
|
178
178
|
end
|
179
179
|
end
|
@@ -189,7 +189,7 @@ module ActionController
|
|
189
189
|
|
190
190
|
def test_render_array
|
191
191
|
get :render_array
|
192
|
-
|
192
|
+
assert_includes @response.content_type, 'application/json'
|
193
193
|
assert_equal '{"my":[{"name":"Name 1","description":"Description 1"}]}', @response.body
|
194
194
|
end
|
195
195
|
end
|
@@ -205,7 +205,7 @@ module ActionController
|
|
205
205
|
|
206
206
|
def test_render_array
|
207
207
|
get :render_array
|
208
|
-
|
208
|
+
assert_includes @response.content_type, 'application/json'
|
209
209
|
assert_equal '{"webLog":[{"name":"Name 1","displayName":"Display Name 1"},{"name":"Name 2","displayName":"Display Name 2"}]}', @response.body
|
210
210
|
end
|
211
211
|
end
|
@@ -223,7 +223,7 @@ module ActionController
|
|
223
223
|
|
224
224
|
def test_render_without_root
|
225
225
|
get :render_without_root
|
226
|
-
|
226
|
+
assert_includes @response.content_type, 'application/json'
|
227
227
|
assert_equal '{"name":"Name 1","displayName":"Display Name 1"}', @response.body
|
228
228
|
end
|
229
229
|
end
|
@@ -242,7 +242,7 @@ module ActionController
|
|
242
242
|
|
243
243
|
def test_render_array_without_root
|
244
244
|
get :render_array_without_root
|
245
|
-
|
245
|
+
assert_includes @response.content_type, 'application/json'
|
246
246
|
assert_equal '[{"name":"Name 1","displayName":"Display Name 1"},{"name":"Name 2","displayName":"Display Name 2"}]', @response.body
|
247
247
|
end
|
248
248
|
end
|
@@ -278,7 +278,7 @@ module ActionController
|
|
278
278
|
@association.embed_in_root = true
|
279
279
|
|
280
280
|
get :render_array_embeding_in_root
|
281
|
-
|
281
|
+
assert_includes @response.content_type, 'application/json'
|
282
282
|
|
283
283
|
assert_equal("{\"my\":[{\"name\":\"Name 1\",\"email\":\"mail@server.com\",\"profile_id\":#{@controller.user.profile.object_id}}],\"profiles\":[{\"name\":\"N1\",\"description\":\"D1\"}]}", @response.body)
|
284
284
|
end
|
data/test/test_helper.rb
CHANGED
@@ -2,6 +2,13 @@ require 'bundler/setup'
|
|
2
2
|
require 'minitest/autorun'
|
3
3
|
require 'active_model_serializers'
|
4
4
|
require 'fixtures/poro'
|
5
|
+
begin
|
6
|
+
require 'rails-controller-testing'
|
7
|
+
Rails::Controller::Testing.install
|
8
|
+
rescue LoadError
|
9
|
+
false # Rails 5 < backward compatibility
|
10
|
+
end
|
11
|
+
|
5
12
|
|
6
13
|
# Ensure backward compatibility with Minitest 4
|
7
14
|
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
|
data/test/tmp/config/routes.rb
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
Rails.application.routes.draw {}
|
@@ -49,6 +49,29 @@ module ActiveModel
|
|
49
49
|
def object.serializer_class; CustomSerializer; end
|
50
50
|
|
51
51
|
assert_equal CustomSerializer, Serializer.serializer_for(object)
|
52
|
+
assert_equal CustomSerializer, Serializer.serializer_for('Custom')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class ModelSerializationNamespaceTest < Minitest::Test
|
57
|
+
def test_namespace
|
58
|
+
test1 = TestNamespace2::Test.new(name: 'Test 1', email: 'test1@test.com', gender: 'M')
|
59
|
+
test2 = TestNamespace2::Test.new(name: 'Test 2', email: 'test2@test.com', gender: 'M')
|
60
|
+
sub_test1 = TestNamespace2::SubTest.new(name: 'Name 1', description: 'Description 1', comments: 'Comments 1')
|
61
|
+
sub_test2 = TestNamespace2::SubTest.new(name: 'Name 2', description: 'Description 2', comments: 'Comments 2')
|
62
|
+
test1.sub_test = sub_test1
|
63
|
+
test2.sub_test = sub_test2
|
64
|
+
|
65
|
+
array = [test1, test2]
|
66
|
+
serializer = ArraySerializer.new(array)
|
67
|
+
|
68
|
+
expected = [
|
69
|
+
{ name: 'Test 1', email: 'test1@test.com', sub_test: { name: 'Name 1', description: 'Description 1' } },
|
70
|
+
{ name: 'Test 2', email: 'test2@test.com', sub_test: { name: 'Name 2', description: 'Description 2' } }
|
71
|
+
]
|
72
|
+
|
73
|
+
assert_equal expected, serializer.serializable_array
|
74
|
+
assert_equal expected, serializer.as_json
|
52
75
|
end
|
53
76
|
end
|
54
77
|
|
@@ -2,7 +2,7 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module ActiveModel
|
4
4
|
class Serializer
|
5
|
-
class HasManyPolymorphicTest <
|
5
|
+
class HasManyPolymorphicTest < Minitest::Test
|
6
6
|
def setup
|
7
7
|
@association = MailSerializer._associations[:attachments]
|
8
8
|
@old_association = @association.dup
|
@@ -2,7 +2,7 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module ActiveModel
|
4
4
|
class Serializer
|
5
|
-
class HasOnePolymorphicTest <
|
5
|
+
class HasOnePolymorphicTest < Minitest::Test
|
6
6
|
def setup
|
7
7
|
@association = InterviewSerializer._associations[:attachment]
|
8
8
|
@old_association = @association.dup
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_model_serializers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- José Valim
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2024-04-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activemodel
|
@@ -89,7 +89,6 @@ files:
|
|
89
89
|
- lib/active_model/serializer/version.rb
|
90
90
|
- lib/active_model/serializer_support.rb
|
91
91
|
- lib/active_model_serializers.rb
|
92
|
-
- lib/active_model_serializers/model/caching.rb
|
93
92
|
- test/benchmark/app.rb
|
94
93
|
- test/benchmark/benchmarking_support.rb
|
95
94
|
- test/benchmark/bm_active_record.rb
|
@@ -167,67 +166,67 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
166
|
- !ruby/object:Gem::Version
|
168
167
|
version: '0'
|
169
168
|
requirements: []
|
170
|
-
rubygems_version: 3.
|
169
|
+
rubygems_version: 3.3.7
|
171
170
|
signing_key:
|
172
171
|
specification_version: 4
|
173
172
|
summary: Bringing consistency and object orientation to model serialization. Works
|
174
173
|
great for client-side MVC frameworks!
|
175
174
|
test_files:
|
176
175
|
- test/benchmark/app.rb
|
177
|
-
- test/benchmark/
|
176
|
+
- test/benchmark/benchmarking_support.rb
|
178
177
|
- test/benchmark/bm_active_record.rb
|
179
|
-
- test/benchmark/
|
180
|
-
- test/benchmark/tmp/miniprofiler/
|
181
|
-
- test/benchmark/tmp/miniprofiler/
|
182
|
-
- test/benchmark/tmp/miniprofiler/mp_timers_qg52tpca3uesdfguee9i
|
183
|
-
- test/benchmark/tmp/miniprofiler/mp_views_127.0.0.1
|
178
|
+
- test/benchmark/setup.rb
|
179
|
+
- test/benchmark/tmp/miniprofiler/mp_timers_6eqewtfgrhitvq5gqm25
|
180
|
+
- test/benchmark/tmp/miniprofiler/mp_timers_8083sx03hu72pxz1a4d0
|
184
181
|
- test/benchmark/tmp/miniprofiler/mp_timers_fyz2gsml4z0ph9kpoy1c
|
182
|
+
- test/benchmark/tmp/miniprofiler/mp_timers_hjry5rc32imd42oxoi48
|
183
|
+
- test/benchmark/tmp/miniprofiler/mp_timers_m8fpoz2cvt3g9agz0bs3
|
185
184
|
- test/benchmark/tmp/miniprofiler/mp_timers_p92m2drnj1i568u3sta0
|
186
|
-
- test/benchmark/tmp/miniprofiler/
|
185
|
+
- test/benchmark/tmp/miniprofiler/mp_timers_qg52tpca3uesdfguee9i
|
186
|
+
- test/benchmark/tmp/miniprofiler/mp_timers_s15t1a6mvxe0z7vjv790
|
187
187
|
- test/benchmark/tmp/miniprofiler/mp_timers_x8kal3d17nfds6vp4kcj
|
188
|
-
- test/benchmark/tmp/miniprofiler/
|
189
|
-
- test/
|
190
|
-
- test/
|
191
|
-
- test/
|
192
|
-
- test/
|
193
|
-
- test/unit/active_model/serializer/key_format_test.rb
|
194
|
-
- test/unit/active_model/serializer/url_helpers_test.rb
|
195
|
-
- test/unit/active_model/serializer/associations_test.rb
|
196
|
-
- test/unit/active_model/serializer/options_test.rb
|
197
|
-
- test/unit/active_model/serializer/attributes_test.rb
|
198
|
-
- test/unit/active_model/serializer/root_test.rb
|
199
|
-
- test/unit/active_model/serializer/meta_test.rb
|
200
|
-
- test/unit/active_model/serializer/has_many_polymorphic_test.rb
|
201
|
-
- test/unit/active_model/serializer/has_one_polymorphic_test.rb
|
202
|
-
- test/unit/active_model/serializer/has_many_test.rb
|
203
|
-
- test/unit/active_model/serializer/has_one_and_has_many_test.rb
|
204
|
-
- test/unit/active_model/serializer/filter_test.rb
|
205
|
-
- test/unit/active_model/serializer/scope_test.rb
|
206
|
-
- test/unit/active_model/default_serializer_test.rb
|
207
|
-
- test/unit/active_model/array_serializer/serialization_test.rb
|
208
|
-
- test/unit/active_model/array_serializer/key_format_test.rb
|
209
|
-
- test/unit/active_model/array_serializer/options_test.rb
|
210
|
-
- test/unit/active_model/array_serializer/only_test.rb
|
211
|
-
- test/unit/active_model/array_serializer/root_test.rb
|
212
|
-
- test/unit/active_model/array_serializer/except_test.rb
|
213
|
-
- test/unit/active_model/array_serializer/meta_test.rb
|
214
|
-
- test/unit/active_model/array_serializer/scope_test.rb
|
215
|
-
- test/unit/active_model/serilizable_test.rb
|
216
|
-
- test/test_app.rb
|
188
|
+
- test/benchmark/tmp/miniprofiler/mp_views_127.0.0.1
|
189
|
+
- test/fixtures/active_record.rb
|
190
|
+
- test/fixtures/poro.rb
|
191
|
+
- test/fixtures/template.html.erb
|
192
|
+
- test/integration/action_controller/namespaced_serialization_test.rb
|
217
193
|
- test/integration/action_controller/serialization_test.rb
|
218
194
|
- test/integration/action_controller/serialization_test_case_test.rb
|
219
|
-
- test/integration/action_controller/namespaced_serialization_test.rb
|
220
195
|
- test/integration/active_record/active_record_test.rb
|
221
|
-
- test/integration/generators/scaffold_controller_generator_test.rb
|
222
196
|
- test/integration/generators/resource_generator_test.rb
|
197
|
+
- test/integration/generators/scaffold_controller_generator_test.rb
|
223
198
|
- test/integration/generators/serializer_generator_test.rb
|
224
|
-
- test/
|
225
|
-
- test/fixtures/template.html.erb
|
226
|
-
- test/fixtures/active_record.rb
|
199
|
+
- test/test_app.rb
|
227
200
|
- test/test_helper.rb
|
228
|
-
- test/tmp/app/serializers/account_serializer.rb
|
229
|
-
- test/tmp/app/controllers/accounts_controller.rb
|
230
201
|
- test/tmp/app/assets/javascripts/accounts.js
|
231
202
|
- test/tmp/app/assets/stylesheets/accounts.css
|
203
|
+
- test/tmp/app/controllers/accounts_controller.rb
|
232
204
|
- test/tmp/app/helpers/accounts_helper.rb
|
205
|
+
- test/tmp/app/serializers/account_serializer.rb
|
233
206
|
- test/tmp/config/routes.rb
|
207
|
+
- test/unit/active_model/array_serializer/except_test.rb
|
208
|
+
- test/unit/active_model/array_serializer/key_format_test.rb
|
209
|
+
- test/unit/active_model/array_serializer/meta_test.rb
|
210
|
+
- test/unit/active_model/array_serializer/only_test.rb
|
211
|
+
- test/unit/active_model/array_serializer/options_test.rb
|
212
|
+
- test/unit/active_model/array_serializer/root_test.rb
|
213
|
+
- test/unit/active_model/array_serializer/scope_test.rb
|
214
|
+
- test/unit/active_model/array_serializer/serialization_test.rb
|
215
|
+
- test/unit/active_model/default_serializer_test.rb
|
216
|
+
- test/unit/active_model/serializer/associations/build_serializer_test.rb
|
217
|
+
- test/unit/active_model/serializer/associations_test.rb
|
218
|
+
- test/unit/active_model/serializer/attributes_test.rb
|
219
|
+
- test/unit/active_model/serializer/config_test.rb
|
220
|
+
- test/unit/active_model/serializer/filter_test.rb
|
221
|
+
- test/unit/active_model/serializer/has_many_polymorphic_test.rb
|
222
|
+
- test/unit/active_model/serializer/has_many_test.rb
|
223
|
+
- test/unit/active_model/serializer/has_one_and_has_many_test.rb
|
224
|
+
- test/unit/active_model/serializer/has_one_polymorphic_test.rb
|
225
|
+
- test/unit/active_model/serializer/has_one_test.rb
|
226
|
+
- test/unit/active_model/serializer/key_format_test.rb
|
227
|
+
- test/unit/active_model/serializer/meta_test.rb
|
228
|
+
- test/unit/active_model/serializer/options_test.rb
|
229
|
+
- test/unit/active_model/serializer/root_test.rb
|
230
|
+
- test/unit/active_model/serializer/scope_test.rb
|
231
|
+
- test/unit/active_model/serializer/url_helpers_test.rb
|
232
|
+
- test/unit/active_model/serilizable_test.rb
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module ActiveModelSerializers
|
2
|
-
class Model
|
3
|
-
module Caching
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
included do
|
7
|
-
attr_writer :updated_at
|
8
|
-
attributes :id
|
9
|
-
end
|
10
|
-
|
11
|
-
# Defaults to the downcased model name and updated_at
|
12
|
-
def cache_key
|
13
|
-
ActiveSupport::Cache.expand_cache_key([
|
14
|
-
self.class.model_name.name.downcase,
|
15
|
-
"#{id}-#{updated_at.strftime('%Y%m%d%H%M%S%9N')}"
|
16
|
-
].compact)
|
17
|
-
end
|
18
|
-
|
19
|
-
# Defaults to the time the serializer file was modified.
|
20
|
-
def updated_at
|
21
|
-
defined?(@updated_at) ? @updated_at : File.mtime(__FILE__)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|