transmutation 0.3.1 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/Gemfile.lock +1 -1
- data/lib/transmutation/core_ext/array.rb +13 -0
- data/lib/transmutation/serializer.rb +9 -3
- data/lib/transmutation/version.rb +1 -1
- data/lib/transmutation.rb +2 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eacb3ed46df9b85dd1389904de77e391c195c09da0739122eefe90d227cdc0bc
|
4
|
+
data.tar.gz: 7f958f8ed0214d4fc328a27d66f5c1c220ee15ccf857e93b801e683687dba3a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 796af841f34b29f39f657344eb0e26da00e84c311de57755fd0812a12db05711c46ad33de58394f76e61c0ba760e8b5a92b1a1cb07fcc3fa090e092a4cef589e
|
7
|
+
data.tar.gz: 12b00efad9d71654a791a6eae379804ec669f98472c1cf469ce6c9bdeeeec27d7fb752c232485cf60f91c50009454fb1c9dcbcf30fa72ca899a85ae434d5a753
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -30,10 +30,10 @@ module Transmutation
|
|
30
30
|
as_json(options).to_json
|
31
31
|
end
|
32
32
|
|
33
|
-
def as_json(
|
33
|
+
def as_json(options = {})
|
34
34
|
attributes_config.each_with_object({}) do |(attr_name, attr_options), hash|
|
35
35
|
if attr_options[:association]
|
36
|
-
hash[attr_name.to_s] = instance_exec(&attr_options[:block]) if @depth + 1 <= @max_depth
|
36
|
+
hash[attr_name.to_s] = instance_exec(&attr_options[:block]).as_json(options) if @depth + 1 <= @max_depth
|
37
37
|
else
|
38
38
|
hash[attr_name.to_s] = attr_options[:block] ? instance_exec(&attr_options[:block]) : object.send(attr_name)
|
39
39
|
end
|
@@ -74,7 +74,13 @@ module Transmutation
|
|
74
74
|
# end
|
75
75
|
def association(association_name, namespace: nil, serializer: nil)
|
76
76
|
block = lambda do
|
77
|
-
serialize(
|
77
|
+
serialize(
|
78
|
+
object.send(association_name),
|
79
|
+
namespace: namespace,
|
80
|
+
serializer: serializer,
|
81
|
+
depth: @depth + 1,
|
82
|
+
max_depth: @max_depth
|
83
|
+
)
|
78
84
|
end
|
79
85
|
|
80
86
|
attributes_config[association_name] = { block: block, association: true }
|
data/lib/transmutation.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: transmutation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nitemaeric
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-09-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: zeitwerk
|
@@ -46,6 +46,7 @@ files:
|
|
46
46
|
- Rakefile
|
47
47
|
- lib/transmutation.rb
|
48
48
|
- lib/transmutation/class_attributes.rb
|
49
|
+
- lib/transmutation/core_ext/array.rb
|
49
50
|
- lib/transmutation/serialization.rb
|
50
51
|
- lib/transmutation/serialization/lookup.rb
|
51
52
|
- lib/transmutation/serialization/lookup/serializer_not_found.rb
|
@@ -77,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
78
|
- !ruby/object:Gem::Version
|
78
79
|
version: '0'
|
79
80
|
requirements: []
|
80
|
-
rubygems_version: 3.5.
|
81
|
+
rubygems_version: 3.5.16
|
81
82
|
signing_key:
|
82
83
|
specification_version: 4
|
83
84
|
summary: Ruby JSON serialization library
|