as_json_representations 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +4 -2
- data/Gemfile.lock +3 -1
- data/lib/as_json_representations/collection.rb +8 -6
- data/lib/as_json_representations/version.rb +1 -1
- 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: ce80219b86473f50512faf0d626b53d41bd8794213eb7aa67c02c73efe0290eb
|
4
|
+
data.tar.gz: 4e79d1d3110b77827d58dbf2510f61d6bd753775cbfd9003da4128d3f017f16f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f452787f29312c9db468b01fb4c13fb6ab364e310909a6f67f817a931db71df6127d2afb2898b4aa3d89f35629b1669647c1862b08789f56846c80fe4173c3a
|
7
|
+
data.tar.gz: ac493e121af24b81ace1f44487a3abd7c5ce75018e050858ebdbfde70c160e3905138b16acf30592a47288c182fe703156eee1b62dea0b87474b75950608de2f
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
3
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in as_json_representations.gemspec
|
6
6
|
gemspec
|
7
|
+
|
8
|
+
gem 'byebug'
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
as_json_representations (0.5.
|
4
|
+
as_json_representations (0.5.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
+
byebug (11.0.1)
|
9
10
|
diff-lcs (1.3)
|
10
11
|
rake (10.5.0)
|
11
12
|
rspec (3.7.0)
|
@@ -28,6 +29,7 @@ PLATFORMS
|
|
28
29
|
DEPENDENCIES
|
29
30
|
as_json_representations!
|
30
31
|
bundler (~> 1.15)
|
32
|
+
byebug
|
31
33
|
rake (~> 10.0)
|
32
34
|
rspec (~> 3.0)
|
33
35
|
|
@@ -9,14 +9,16 @@ module AsJsonRepresentations
|
|
9
9
|
def as_json(options={})
|
10
10
|
subject = self
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
if respond_to?(:klass) && klass.respond_to?(:representations)
|
13
|
+
# call supported methods of ActiveRecord::QueryMethods
|
14
|
+
%i[includes eager_load].each do |method|
|
15
|
+
next unless respond_to? method
|
15
16
|
|
16
|
-
|
17
|
+
args = klass.representations.dig(options[:representation], method)
|
17
18
|
|
18
|
-
|
19
|
-
|
19
|
+
# we need to reassign because ActiveRecord returns new object
|
20
|
+
subject = subject.public_send(method, args) if args
|
21
|
+
end
|
20
22
|
end
|
21
23
|
|
22
24
|
return super if respond_to? :super
|
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.5.
|
4
|
+
version: 0.5.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: 2020-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -92,7 +92,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
|
-
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.7.3
|
96
97
|
signing_key:
|
97
98
|
specification_version: 4
|
98
99
|
summary: Creates representations of your model data
|