alba 3.0.1 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +2 -2
- data/CHANGELOG.md +13 -0
- data/CODE_OF_CONDUCT.md +104 -46
- data/README.md +85 -41
- data/docs/migrate_from_jbuilder.md +1 -1
- data/lib/alba/nested_attribute.rb +3 -2
- data/lib/alba/resource.rb +10 -10
- data/lib/alba/version.rb +1 -1
- data/lib/alba.rb +3 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a2aa4a1fc6859ca700fefbe63af11657031743b9ad6c4ec9f97c7d7eac2cef7
|
4
|
+
data.tar.gz: 8703816ac23d30e432053c6836a8ed3e517f318a9924ae4bf67e5b3cff79f666
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abd511841f6100e00e53687a3f4b7a58a04645090f3e7204edec2c7f8ea438d70e9014b576e56aae302db293796ccd793aa4d976b4241f91f25a1cf15d0e19e6
|
7
|
+
data.tar.gz: bf76202cdf514b5134b5a3f1e17b17cca78dbb9c9f1029f562d9d4ccc992c9d8aaeefbf01d1c45d1f4aff658d53a21e24b0caa279b6852e1516765c6ce62d99d
|
data/.github/workflows/main.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
name:
|
1
|
+
name: CI
|
2
2
|
|
3
3
|
on: [push,pull_request]
|
4
4
|
|
@@ -8,7 +8,7 @@ jobs:
|
|
8
8
|
fail-fast: false
|
9
9
|
matrix:
|
10
10
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
11
|
-
ruby: ['3.0', 3.1, 3.2, head, jruby
|
11
|
+
ruby: ['3.0', 3.1, 3.2, head, truffleruby] # TODO: Add jruby after the error is resolved
|
12
12
|
gemfile: [all, without_active_support, without_oj]
|
13
13
|
exclude:
|
14
14
|
- os: windows-latest
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [3.0.3] 2023-12-25
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
|
13
|
+
- Make `as_json` compatible with Rails [#350](https://github.com/okuramasafumi/alba/pull/350)
|
14
|
+
- Fix circular association for nested_attribute [#353](https://github.com/okuramasafumi/alba/pull/353)
|
15
|
+
|
16
|
+
## [3.0.2] 2023-12-05
|
17
|
+
|
18
|
+
### Fixed
|
19
|
+
|
20
|
+
- Fixed warning when `location` option is given to `render json:` in Rails [#348](https://github.com/okuramasafumi/alba/pull/348)
|
21
|
+
|
9
22
|
## [3.0.1] 2023-10-13
|
10
23
|
|
11
24
|
### Fixed
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -1,74 +1,132 @@
|
|
1
|
+
|
1
2
|
# Contributor Covenant Code of Conduct
|
2
3
|
|
3
4
|
## Our Pledge
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
nationality, personal appearance, race, religion, or sexual
|
10
|
-
orientation.
|
6
|
+
We as members, contributors, and leaders pledge to make participation in our
|
7
|
+
community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
9
|
+
identity and expression, level of experience, education, socio-economic status,
|
10
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
11
|
+
identity and orientation.
|
12
|
+
|
13
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
14
|
+
diverse, inclusive, and healthy community.
|
11
15
|
|
12
16
|
## Our Standards
|
13
17
|
|
14
|
-
Examples of behavior that contributes to
|
15
|
-
include:
|
18
|
+
Examples of behavior that contributes to a positive environment for our
|
19
|
+
community include:
|
16
20
|
|
17
|
-
*
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
19
|
-
*
|
20
|
-
*
|
21
|
-
|
21
|
+
* Demonstrating empathy and kindness toward other people
|
22
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
23
|
+
* Giving and gracefully accepting constructive feedback
|
24
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
25
|
+
and learning from the experience
|
26
|
+
* Focusing on what is best not just for us as individuals, but for the overall
|
27
|
+
community
|
22
28
|
|
23
|
-
Examples of unacceptable behavior
|
29
|
+
Examples of unacceptable behavior include:
|
24
30
|
|
25
|
-
* The use of sexualized language or imagery and
|
26
|
-
|
27
|
-
* Trolling, insulting
|
31
|
+
* The use of sexualized language or imagery, and sexual attention or advances of
|
32
|
+
any kind
|
33
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
28
34
|
* Public or private harassment
|
29
|
-
* Publishing others' private information, such as a physical or
|
30
|
-
|
35
|
+
* Publishing others' private information, such as a physical or email address,
|
36
|
+
without their explicit permission
|
31
37
|
* Other conduct which could reasonably be considered inappropriate in a
|
32
38
|
professional setting
|
33
39
|
|
34
|
-
##
|
40
|
+
## Enforcement Responsibilities
|
35
41
|
|
36
|
-
|
37
|
-
behavior and
|
38
|
-
response to any
|
42
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
43
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
44
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
45
|
+
or harmful.
|
39
46
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
threatening, offensive, or harmful.
|
47
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
48
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
49
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
50
|
+
decisions when appropriate.
|
45
51
|
|
46
52
|
## Scope
|
47
53
|
|
48
|
-
This Code of Conduct applies
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
representative at an online or offline event.
|
53
|
-
further defined and clarified by project maintainers.
|
54
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
55
|
+
an individual is officially representing the community in public spaces.
|
56
|
+
Examples of representing our community include using an official e-mail address,
|
57
|
+
posting via an official social media account, or acting as an appointed
|
58
|
+
representative at an online or offline event.
|
54
59
|
|
55
60
|
## Enforcement
|
56
61
|
|
57
62
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported
|
59
|
-
complaints will be reviewed and investigated and
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
+
reported to the community leaders responsible for enforcement at masafumi.o1988@gmail.com .
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
65
|
+
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
67
|
+
reporter of any incident.
|
68
|
+
|
69
|
+
## Enforcement Guidelines
|
70
|
+
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
73
|
+
|
74
|
+
### 1. Correction
|
75
|
+
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
77
|
+
unprofessional or unwelcome in the community.
|
78
|
+
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
82
|
+
|
83
|
+
### 2. Warning
|
63
84
|
|
64
|
-
|
65
|
-
|
66
|
-
|
85
|
+
**Community Impact**: A violation through a single incident or series of
|
86
|
+
actions.
|
87
|
+
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
92
|
+
like social media. Violating these terms may lead to a temporary or permanent
|
93
|
+
ban.
|
94
|
+
|
95
|
+
### 3. Temporary Ban
|
96
|
+
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
98
|
+
sustained inappropriate behavior.
|
99
|
+
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
101
|
+
communication with the community for a specified period of time. No public or
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
104
|
+
Violating these terms may lead to a permanent ban.
|
105
|
+
|
106
|
+
### 4. Permanent Ban
|
107
|
+
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
111
|
+
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within the
|
113
|
+
community.
|
67
114
|
|
68
115
|
## Attribution
|
69
116
|
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
71
|
-
available at
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
118
|
+
version 2.1, available at
|
119
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
120
|
+
|
121
|
+
Community Impact Guidelines were inspired by
|
122
|
+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
123
|
+
|
124
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
125
|
+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
126
|
+
[https://www.contributor-covenant.org/translations][translations].
|
72
127
|
|
73
|
-
[homepage]: https://contributor-covenant.org
|
74
|
-
[
|
128
|
+
[homepage]: https://www.contributor-covenant.org
|
129
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
130
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
131
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
132
|
+
[translations]: https://www.contributor-covenant.org/translations
|
data/README.md
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
[![Maintainability](https://api.codeclimate.com/v1/badges/fdab4cc0de0b9addcfe8/maintainability)](https://codeclimate.com/github/okuramasafumi/alba/maintainability)
|
7
7
|
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/okuramasafumi/alba)
|
8
8
|
![GitHub](https://img.shields.io/github/license/okuramasafumi/alba)
|
9
|
+
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](code_of_conduct.md)
|
9
10
|
|
10
11
|
# Alba
|
11
12
|
|
@@ -14,9 +15,11 @@ Alba is a JSON serializer for Ruby, JRuby, and TruffleRuby.
|
|
14
15
|
## IMPORTANT NOTICE
|
15
16
|
|
16
17
|
Both version `3.0.0` and `2.4.2` contain important bug fix.
|
17
|
-
However, version `3.0.0` has some bugs (see https://github.com/okuramasafumi/alba/issues/342).
|
18
|
+
~~However, version `3.0.0` has some bugs (see https://github.com/okuramasafumi/alba/issues/342).
|
18
19
|
Until they get fixed, it's highly recommended to upgrade to version `2.4.2`.
|
19
|
-
Dependabot and similar tools might create an automated Pull Request to upgrade to `3.0.0`, so it might be required to upgrade to `2.4.2` manually
|
20
|
+
Dependabot and similar tools might create an automated Pull Request to upgrade to `3.0.0`, so it might be required to upgrade to `2.4.2` manually.~~
|
21
|
+
Version `3.0.1` has been released so Ruby 3 users should upgrade to `3.0.1`.
|
22
|
+
For Ruby 2 users, it's highly recommended to upgrade to `2.4.2`.
|
20
23
|
Sorry for the inconvenience.
|
21
24
|
|
22
25
|
## TL;DR
|
@@ -289,72 +292,77 @@ class UserResource
|
|
289
292
|
end
|
290
293
|
```
|
291
294
|
|
292
|
-
####
|
295
|
+
#### Methods conflict
|
293
296
|
|
294
|
-
|
297
|
+
Consider following code:
|
295
298
|
|
296
299
|
```ruby
|
297
|
-
class
|
298
|
-
|
299
|
-
|
300
|
-
def initialize(id, name, email)
|
301
|
-
@id = id
|
302
|
-
@name = name
|
303
|
-
@email = email
|
304
|
-
end
|
305
|
-
|
306
|
-
def name_with_email
|
307
|
-
'dummy!'
|
300
|
+
class Foo
|
301
|
+
def bar
|
302
|
+
'This is Foo'
|
308
303
|
end
|
309
304
|
end
|
310
305
|
|
311
|
-
class
|
306
|
+
class FooResource
|
312
307
|
include Alba::Resource
|
313
308
|
|
314
|
-
|
315
|
-
|
316
|
-
attributes :id, :name, :name_with_email
|
309
|
+
attributes :bar
|
317
310
|
|
318
|
-
|
319
|
-
|
320
|
-
def name_with_email(user)
|
321
|
-
"#{user.name}: #{user.email}"
|
311
|
+
def bar
|
312
|
+
'This is FooResource'
|
322
313
|
end
|
323
314
|
end
|
324
315
|
|
325
|
-
|
326
|
-
UserResource.new(user).serialize
|
327
|
-
# => '{"user":{"id":1,"name":"Masafumi OKURA","name_with_email":"dummy!"}}'
|
316
|
+
FooResource.new(Foo.new).serialize
|
328
317
|
```
|
329
318
|
|
330
|
-
|
319
|
+
By default, Alba create the JSON as `'{"bar":"This is FooResource"}'`. This means Alba calls a method on a Resource class and doesn't call a method on a target object. This rule is applied to methods that are explicitly defined on Resource class, so methods that Resource class inherits from `Object` class such as `format` are ignored.
|
331
320
|
|
332
321
|
```ruby
|
333
|
-
|
322
|
+
class Foo
|
323
|
+
def format
|
324
|
+
'This is Foo'
|
325
|
+
end
|
326
|
+
end
|
334
327
|
|
335
|
-
class
|
328
|
+
class FooResource
|
336
329
|
include Alba::Resource
|
337
330
|
|
338
|
-
|
331
|
+
attributes :bar
|
339
332
|
|
340
|
-
|
333
|
+
# Here, `format` method is available
|
334
|
+
end
|
341
335
|
|
342
|
-
|
336
|
+
FooResource.new(Foo.new).serialize
|
337
|
+
# => '{"bar":"This is Foo"}'
|
338
|
+
```
|
343
339
|
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
340
|
+
If you'd like Alba to call methods on a target object, use `prefer_object_method!` like below.
|
341
|
+
|
342
|
+
```ruby
|
343
|
+
class Foo
|
344
|
+
def bar
|
345
|
+
'This is Foo'
|
348
346
|
end
|
349
347
|
end
|
350
348
|
|
351
|
-
|
352
|
-
|
353
|
-
# => '{"user":{"id":1,"name":"Masafumi OKURA","name_with_email":"Masafumi OKURA: masafumi@example.com"}}'
|
354
|
-
```
|
349
|
+
class FooResource
|
350
|
+
include Alba::Resource
|
355
351
|
|
356
|
-
|
352
|
+
prefer_object_method! # <- important
|
357
353
|
|
354
|
+
attributes :bar
|
355
|
+
|
356
|
+
# This is not called
|
357
|
+
def bar
|
358
|
+
'This is FooResource'
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
FooResource.new(Foo.new).serialize
|
363
|
+
# => '{"bar":"This is Foo"}'
|
364
|
+
```
|
365
|
+
|
358
366
|
#### Params
|
359
367
|
|
360
368
|
You can pass a Hash to the resource for internal use. It can be used as "flags" to control attribute content.
|
@@ -1449,6 +1457,8 @@ end
|
|
1449
1457
|
|
1450
1458
|
Within `helper` block, all methods should be defined without `self.`.
|
1451
1459
|
|
1460
|
+
`helper`
|
1461
|
+
|
1452
1462
|
### Caching
|
1453
1463
|
|
1454
1464
|
Currently, Alba doesn't support caching, primarily due to the behavior of `ActiveRecord::Relation`'s cache. See [the issue](https://github.com/rails/rails/issues/41784).
|
@@ -1555,6 +1565,40 @@ end
|
|
1555
1565
|
|
1556
1566
|
In this way we have shorter and cleaner code. Note that we need to use `send` or `public_send` in `attribute` block to get attribute data.
|
1557
1567
|
|
1568
|
+
#### Using `helper`
|
1569
|
+
|
1570
|
+
When we `extend AlbaExtension` like above, it's not available in inline associations.
|
1571
|
+
|
1572
|
+
```ruby
|
1573
|
+
class BarResource
|
1574
|
+
include Alba::Resource
|
1575
|
+
extend AlbaExtension
|
1576
|
+
# other attributes
|
1577
|
+
formatted_time_attributes :created_at, :updated_at
|
1578
|
+
|
1579
|
+
one :something do
|
1580
|
+
# This DOES NOT work!
|
1581
|
+
formatted_time_attributes :updated_at
|
1582
|
+
end
|
1583
|
+
end
|
1584
|
+
```
|
1585
|
+
|
1586
|
+
In this case, we can use [helper](#helper) instead of `extend`.
|
1587
|
+
|
1588
|
+
```ruby
|
1589
|
+
class BarResource
|
1590
|
+
include Alba::Resource
|
1591
|
+
helper AlbaExtension # HERE!
|
1592
|
+
# other attributes
|
1593
|
+
formatted_time_attributes :created_at, :updated_at
|
1594
|
+
|
1595
|
+
one :something do
|
1596
|
+
# This WORKS!
|
1597
|
+
formatted_time_attributes :updated_at
|
1598
|
+
end
|
1599
|
+
end
|
1600
|
+
```
|
1601
|
+
|
1558
1602
|
### Debugging
|
1559
1603
|
|
1560
1604
|
Debugging is not easy. If you find Alba not working as you expect, there are a few things to do:
|
@@ -11,12 +11,13 @@ module Alba
|
|
11
11
|
|
12
12
|
# @param object [Object] the object being serialized
|
13
13
|
# @param params [Hash] params Hash inherited from Resource
|
14
|
+
# @param within [Object, nil, false, true] determines what associations to be serialized. If not set, it serializes all associations.
|
14
15
|
# @return [Hash] hash serialized from running the class body in the object
|
15
|
-
def value(object:, params:)
|
16
|
+
def value(object:, params:, within:)
|
16
17
|
resource_class = Alba.resource_class
|
17
18
|
resource_class.transform_keys(@key_transformation)
|
18
19
|
resource_class.class_eval(&@block)
|
19
|
-
resource_class.new(object, params: params).serializable_hash
|
20
|
+
resource_class.new(object, params: params, within: within).serializable_hash
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
data/lib/alba/resource.rb
CHANGED
@@ -26,7 +26,7 @@ module Alba
|
|
26
26
|
base.class_eval do
|
27
27
|
# Initialize
|
28
28
|
INTERNAL_VARIABLES.each do |name, initial|
|
29
|
-
instance_variable_set("@#{name}", initial.dup) unless instance_variable_defined?("@#{name}")
|
29
|
+
instance_variable_set(:"@#{name}", initial.dup) unless instance_variable_defined?(:"@#{name}")
|
30
30
|
setup_method_body << "@#{name} = self.class.#{name};"
|
31
31
|
end
|
32
32
|
base.define_method(:encode, Alba.encoder)
|
@@ -71,10 +71,11 @@ module Alba
|
|
71
71
|
|
72
72
|
# Returns a Hash correspondng {#serialize}
|
73
73
|
#
|
74
|
+
# @param _options [Hash] dummy parameter for Rails compatibility
|
74
75
|
# @param root_key [Symbol, nil, true]
|
75
76
|
# @param meta [Hash] metadata for this seialization
|
76
77
|
# @return [Hash]
|
77
|
-
def as_json(root_key: nil, meta: {})
|
78
|
+
def as_json(_options = {}, root_key: nil, meta: {})
|
78
79
|
key = root_key.nil? ? fetch_key : root_key
|
79
80
|
key = Alba.regularize_key(key)
|
80
81
|
if key && !key.empty?
|
@@ -96,12 +97,11 @@ module Alba
|
|
96
97
|
private
|
97
98
|
|
98
99
|
def _to_json(root_key, meta, options)
|
99
|
-
options.
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
message = "You passed #{names.join(', ')} options but ignored. Please refer to the document: https://github.com/okuramasafumi/alba/blob/main/docs/rails.md"
|
100
|
+
confusing_options = options.keys.select { |k| k.to_sym == :only || k.to_sym == :except }
|
101
|
+
unless confusing_options.empty?
|
102
|
+
confusing_options.sort!
|
103
|
+
confusing_options.map! { |s| "\"#{s}\"" }
|
104
|
+
message = "You passed #{confusing_options.join(' and ')} options but ignored. Please refer to the document: https://github.com/okuramasafumi/alba/blob/main/docs/rails.md"
|
105
105
|
Kernel.warn(message)
|
106
106
|
end
|
107
107
|
serialize(root_key: root_key, meta: meta)
|
@@ -247,7 +247,7 @@ module Alba
|
|
247
247
|
when Proc then instance_exec(obj, &attribute)
|
248
248
|
when Alba::Association then yield_if_within(attribute.name.to_sym) { |within| attribute.to_h(obj, params: params, within: within) }
|
249
249
|
when TypedAttribute then attribute.value(obj)
|
250
|
-
when NestedAttribute then attribute.value(object: obj, params: params)
|
250
|
+
when NestedAttribute then attribute.value(object: obj, params: params, within: @within)
|
251
251
|
when ConditionalAttribute then attribute.with_passing_condition(resource: self, object: obj) { |attr| fetch_attribute(obj, key, attr) }
|
252
252
|
else raise ::Alba::Error, "Unsupported type of attribute: #{attribute.class}"
|
253
253
|
end
|
@@ -317,7 +317,7 @@ module Alba
|
|
317
317
|
# @private
|
318
318
|
def inherited(subclass)
|
319
319
|
super
|
320
|
-
INTERNAL_VARIABLES.each_key { |name| subclass.instance_variable_set("@#{name}", instance_variable_get("@#{name}").clone) }
|
320
|
+
INTERNAL_VARIABLES.each_key { |name| subclass.instance_variable_set(:"@#{name}", instance_variable_get(:"@#{name}").clone) }
|
321
321
|
end
|
322
322
|
|
323
323
|
# Defining methods for DSLs and disable parameter number check since for users' benefits increasing params is fine
|
data/lib/alba/version.rb
CHANGED
data/lib/alba.rb
CHANGED
@@ -114,11 +114,14 @@ module Alba
|
|
114
114
|
raise Alba::Error, 'Inference is disabled so Alba cannot infer resource name. Set inflector before use.' unless Alba.inflector
|
115
115
|
|
116
116
|
const_parent = nesting.nil? ? Object : Object.const_get(nesting)
|
117
|
+
# rubocop-performance 1.20.2 might resolve this
|
118
|
+
# rubocop:disable Performance/StringIdentifierArgument
|
117
119
|
begin
|
118
120
|
const_parent.const_get("#{inflector.classify(name)}Resource")
|
119
121
|
rescue NameError # Retry for serializer
|
120
122
|
const_parent.const_get("#{inflector.classify(name)}Serializer")
|
121
123
|
end
|
124
|
+
# rubocop:enable Performance/StringIdentifierArgument
|
122
125
|
end
|
123
126
|
|
124
127
|
# Configure Alba to symbolize keys
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OKURA Masafumi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Alba is the fastest JSON serializer for Ruby. It focuses on performance,
|
14
14
|
flexibility and usability.
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|
97
|
-
rubygems_version: 3.4.
|
97
|
+
rubygems_version: 3.4.22
|
98
98
|
signing_key:
|
99
99
|
specification_version: 4
|
100
100
|
summary: Alba is the fastest JSON serializer for Ruby.
|