as_json_representations 0.5.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: daa006efc48883832cee9320fdd7c6f97857739664befca6e43a9926b7e32f87
4
- data.tar.gz: aca509444daca9ce848074ddab33a5e7db143d5bc4aef381fb55e8c62f208fc5
3
+ metadata.gz: ce80219b86473f50512faf0d626b53d41bd8794213eb7aa67c02c73efe0290eb
4
+ data.tar.gz: 4e79d1d3110b77827d58dbf2510f61d6bd753775cbfd9003da4128d3f017f16f
5
5
  SHA512:
6
- metadata.gz: 171f411f75287d344bfc1372dbde7fdaf97384c149ca704ef948eff4330d23fbb91e2f15057a42f3184e783a767025da2de26aaa931e3e68c062a25dcdcd372c
7
- data.tar.gz: 0257036af2c8696a39a11afe994523c178185c705a00bb448cbfd04125cd457701420c3c122cad7605ca14ddd6cc89f1039742e18f5176c3c22d51d962b94840
6
+ metadata.gz: 8f452787f29312c9db468b01fb4c13fb6ab364e310909a6f67f817a931db71df6127d2afb2898b4aa3d89f35629b1669647c1862b08789f56846c80fe4173c3a
7
+ data.tar.gz: ac493e121af24b81ace1f44487a3abd7c5ce75018e050858ebdbfde70c160e3905138b16acf30592a47288c182fe703156eee1b62dea0b87474b75950608de2f
data/.gitignore CHANGED
@@ -9,4 +9,5 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ .byebug_history
12
13
  *.gem
data/Gemfile CHANGED
@@ -1,6 +1,8 @@
1
- source "https://rubygems.org"
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'
@@ -1,11 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- as_json_representations (0.5.0)
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
- # call supported methods of ActiveRecord::QueryMethods
13
- %i[includes eager_load].each do |method|
14
- next unless respond_to? method
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
- args = klass.representations.dig(options[:representation], method)
17
+ args = klass.representations.dig(options[:representation], method)
17
18
 
18
- # we need to reassign because ActiveRecord returns new object
19
- subject = subject.public_send(method, args) if args
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
@@ -1,3 +1,3 @@
1
1
  module AsJsonRepresentations
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.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.5.0
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: 2019-08-24 00:00:00.000000000 Z
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
- rubygems_version: 3.0.3
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