json_serializers 2.0.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.
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ if Gem.loaded_specs['oj']
4
+ require 'oj'
5
+
6
+ # NOTE: We automatically set the necessary configuration unless it had been
7
+ # explicitly set beforehand.
8
+ unless Oj.default_options[:use_raw_json]
9
+ require 'rails'
10
+ Oj.optimize_rails
11
+ Oj.default_options = { mode: :rails, use_raw_json: true }
12
+ end
13
+
14
+ # NOTE: Add an optimization to make it easier to work with a StringWriter
15
+ # transparently in different scenarios.
16
+ class Oj::StringWriter
17
+ alias original_as_json as_json
18
+
19
+ # Internal: ActiveSupport can pass an options argument to `as_json` when
20
+ # serializing a Hash or Array.
21
+ def as_json(_options = nil)
22
+ original_as_json
23
+ end
24
+
25
+ # Internal: We can use `to_s` directly, this is not important but gives a
26
+ # slight boost to a few use cases that use it for caching in Memcached.
27
+ def to_json(_options = nil)
28
+ to_s.delete_suffix("\n")
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/railtie'
4
+ require 'action_controller'
5
+ require 'action_controller/railtie'
6
+
7
+ require 'json_serializers'
8
+ require 'json_serializers/controller_serialization'
9
+
10
+ # Internal: Allows to pass JSON serializers as options in `render`.
11
+ class JsonSerializers::Railtie < Rails::Railtie
12
+ initializer 'json_serializers.action_controller' do
13
+ ActiveSupport.on_load(:action_controller) do
14
+ include(JsonSerializers::ControllerSerialization)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JsonSerializers
4
+ VERSION = '2.0.3'
5
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'json_serializers/version'
5
+ require 'json_serializers/setup'
6
+ require 'json_serializers/serializer'
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: json_serializers
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Maximo Mussini
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-05-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: json_serializers minimizes object allocations, while providing a similar
14
+ API to Active Model Serializers.
15
+ email:
16
+ - maximomussini@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - CHANGELOG.md
22
+ - README.md
23
+ - lib/json_serializers.rb
24
+ - lib/json_serializers/compat.rb
25
+ - lib/json_serializers/controller_serialization.rb
26
+ - lib/json_serializers/json_string_encoder.rb
27
+ - lib/json_serializers/json_value.rb
28
+ - lib/json_serializers/memo.rb
29
+ - lib/json_serializers/serializer.rb
30
+ - lib/json_serializers/setup.rb
31
+ - lib/json_serializers/sugar.rb
32
+ - lib/json_serializers/version.rb
33
+ homepage: https://github.com/ElMassimo/oj_serializers
34
+ licenses:
35
+ - MIT
36
+ metadata:
37
+ homepage_uri: https://github.com/ElMassimo/oj_serializers
38
+ source_code_uri: https://github.com/ElMassimo/oj_serializers
39
+ changelog_uri: https://github.com/ElMassimo/oj_serializers/blob/master/CHANGELOG.md
40
+ rubygems_mfa_required: 'true'
41
+ post_install_message:
42
+ rdoc_options: []
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 2.7.0
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ requirements: []
56
+ rubygems_version: 3.5.16
57
+ signing_key:
58
+ specification_version: 4
59
+ summary: A lighter JSON serializer for Ruby Objects in Rails. Easily migrate away
60
+ from Active Model Serializers.
61
+ test_files: []