as_json_representations 0.6.0 → 0.6.1
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 +9 -0
- data/Gemfile.lock +3 -3
- data/README.md +2 -0
- data/as_json_representations.gemspec +1 -1
- data/lib/as_json_representations/collection.rb +3 -2
- data/lib/as_json_representations/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a8d39dc3e4957b77b602263d9193606cd5ab4989fbb035512eb921c7df2bd8d
|
4
|
+
data.tar.gz: bd36c60219711176968616cebc6851afbd73e8e4af4543d4eb319570fc1d5be0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57cfcc22d77af7b41ab3540c7692ef12e49e9fad3c1b23f347782154db756a5717438e115d52d5b4bad32b6fd8cf3afac303ce4277797483ff9c7bd842154d31
|
7
|
+
data.tar.gz: 546a24dea5c3e795761b1ff9ad693401da479ab38061865920372bb3272b1c89207f7c46d4b6af41bc00d613e6dd35ead5b24eafa2e7748c34667f1394bebfd7
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [v0.6.1] - 2022-02-24
|
8
|
+
- Fixed bug when use string as representation name with collections
|
9
|
+
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
as_json_representations (0.6.
|
4
|
+
as_json_representations (0.6.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -28,10 +28,10 @@ PLATFORMS
|
|
28
28
|
|
29
29
|
DEPENDENCIES
|
30
30
|
as_json_representations!
|
31
|
-
bundler (~>
|
31
|
+
bundler (~> 2.3)
|
32
32
|
byebug
|
33
33
|
rake (~> 13.0)
|
34
34
|
rspec (~> 3.0)
|
35
35
|
|
36
36
|
BUNDLED WITH
|
37
|
-
|
37
|
+
2.3.8
|
data/README.md
CHANGED
@@ -155,6 +155,8 @@ When you includes representation module (parent) into other module (child):
|
|
155
155
|
You can use this ActiveRecord option when you define a representation:
|
156
156
|
|
157
157
|
* [includes](https://apidock.com/rails/ActiveRecord/QueryMethods/includes)
|
158
|
+
* [eager_load](https://apidock.com/rails/ActiveRecord/QueryMethods/eager_load)
|
159
|
+
* [preload](https://apidock.com/rails/ActiveRecord/QueryMethods/preload)
|
158
160
|
|
159
161
|
```
|
160
162
|
representation :private, includes: [:city]
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ['lib']
|
23
23
|
|
24
|
-
spec.add_development_dependency 'bundler', '~>
|
24
|
+
spec.add_development_dependency 'bundler', '~> 2.3'
|
25
25
|
spec.add_development_dependency 'rake', '~> 13.0'
|
26
26
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
27
|
end
|
@@ -8,13 +8,14 @@ module AsJsonRepresentations
|
|
8
8
|
base.class_eval do
|
9
9
|
def as_json(options={})
|
10
10
|
subject = self
|
11
|
+
representation = options[:representation]&.to_sym
|
11
12
|
|
12
|
-
if respond_to?(:klass) && klass.respond_to?(:representations)
|
13
|
+
if representation && respond_to?(:klass) && klass.respond_to?(:representations)
|
13
14
|
# call supported methods of ActiveRecord::QueryMethods
|
14
15
|
QUERY_METHODS.each do |method|
|
15
16
|
next unless respond_to? method
|
16
17
|
|
17
|
-
args = klass.representations.dig(
|
18
|
+
args = klass.representations.dig(representation, method)
|
18
19
|
|
19
20
|
# we need to reassign because ActiveRecord returns new object
|
20
21
|
subject = subject.public_send(method, args) if args
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: as_json_representations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rjurado01
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- ".gitignore"
|
63
63
|
- ".rspec"
|
64
64
|
- ".travis.yml"
|
65
|
+
- CHANGELOG.md
|
65
66
|
- Gemfile
|
66
67
|
- Gemfile.lock
|
67
68
|
- LICENSE.txt
|
@@ -92,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
93
|
- !ruby/object:Gem::Version
|
93
94
|
version: '0'
|
94
95
|
requirements: []
|
95
|
-
rubygems_version: 3.1.
|
96
|
+
rubygems_version: 3.1.4
|
96
97
|
signing_key:
|
97
98
|
specification_version: 4
|
98
99
|
summary: Creates representations of your model data
|