as_json_representations 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2411f12b165485b579cf9650b2ee1de6d197daa4fdbea9ecd952b31b0c68a8f
4
- data.tar.gz: 3c4e24fb9e8d229ee9177e605535cc8ab2bdd6a968b15d1e611f1abea1965821
3
+ metadata.gz: 1a8d39dc3e4957b77b602263d9193606cd5ab4989fbb035512eb921c7df2bd8d
4
+ data.tar.gz: bd36c60219711176968616cebc6851afbd73e8e4af4543d4eb319570fc1d5be0
5
5
  SHA512:
6
- metadata.gz: ab50b7d16894eb166c95a833d433b8138380b9f5eb51ff01719d61a32b550e623e1801bcb413abee8e3c63accfeabc2fe616316199e9989b7c027b91f6cf4543
7
- data.tar.gz: 294d76aaeb638dbe1fa55c04c89300a0c376c4af9739d19d72c7bd450562f08fac89efb85e7c798eeb773fae0a68dbefe70feb6b159fa94a42ba9fa8e3b9cb50
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.0)
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 (~> 1.15)
31
+ bundler (~> 2.3)
32
32
  byebug
33
33
  rake (~> 13.0)
34
34
  rspec (~> 3.0)
35
35
 
36
36
  BUNDLED WITH
37
- 1.17.3
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', '~> 1.15'
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(options[:representation], method)
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
@@ -1,3 +1,3 @@
1
1
  module AsJsonRepresentations
2
- VERSION = '0.6.0'
2
+ VERSION = '0.6.1'
3
3
  end
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.0
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: 2020-07-22 00:00:00.000000000 Z
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: '1.15'
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: '1.15'
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.2
96
+ rubygems_version: 3.1.4
96
97
  signing_key:
97
98
  specification_version: 4
98
99
  summary: Creates representations of your model data