as_json_representations 0.4.0 → 0.4.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: c281672043920d58c37a13f7d482d4cf28eed8cb1f76f6cdbe96c477715cebae
4
- data.tar.gz: 1f8e071bd25a5206e738957fc7314ed0db9ed9708c72bee400cbd8bfcaf6e7e5
3
+ metadata.gz: d489e6472aa1956629b9a73dfa7fe239e1ae9cd3d794f23a69085da4909bcead
4
+ data.tar.gz: a1eff31bbd91cc4ba2c04cc2518b5b4a2e90864fa20161230f21b4d4882fd0a0
5
5
  SHA512:
6
- metadata.gz: 0043c6b6ff892e063b7cb74ca7cb567d760ce034e48a7f198b5afa60afa379506c591963c8c4a83176fe45cbfd413fd2e4b4e30d198f2e77c330e6ea0566a2ca
7
- data.tar.gz: 82b77be08e2b719af905fd33c90ff43954c32ca2705fc0ca02b670033a2d44c9f4d1036f1ed2836945cd02d06e8a69fef3685ce0679d74498c6be7e6a988d2ee
6
+ metadata.gz: e1c6f1861aecfac8d575788cc90acb4d313dc51e2f045968f26819741f0a5260c8366c5a734ff5f0697891218736f5a18eb28da2b8a532e95640aea1579555be
7
+ data.tar.gz: d7a542c0ddda417baad9977535c42160ebc8880a56d22491b11ad35b0cf708736450080ec34787cf3632b525b0300042819f1a93368c72228e46004b1de73f54
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- as_json_representations (0.4.0)
4
+ as_json_representations (0.4.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -4,13 +4,17 @@ module AsJsonRepresentations
4
4
  module ClassMethods
5
5
  def representation(name, options={}, &block)
6
6
  @representations ||= {}
7
- @representations[name] = options.merge(name: name, block: block)
7
+ @representations[name] = options.merge(name: name, class: self, block: block)
8
8
  end
9
9
 
10
10
  def representations
11
11
  @representations
12
12
  end
13
13
 
14
+ def parent
15
+ @parent
16
+ end
17
+
14
18
  def find_representation(name)
15
19
  representations[name] || @parent&.find_representation(name) if name
16
20
  end
@@ -26,9 +30,12 @@ module AsJsonRepresentations
26
30
  &representation[:block]
27
31
  ).merge(data)
28
32
 
29
- representation = [representation[:name], true].include?(representation[:extend]) ?
30
- @parent.find_representation(representation[:name]) :
31
- find_representation(representation[:extend])
33
+ representation =
34
+ if representation[:extend] == true
35
+ representation[:class].parent&.find_representation(representation[:name])
36
+ else
37
+ find_representation(representation[:extend])
38
+ end
32
39
 
33
40
  return data unless representation
34
41
  end
@@ -1,3 +1,3 @@
1
1
  module AsJsonRepresentations
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.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.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - rjurado01
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-23 00:00:00.000000000 Z
11
+ date: 2018-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  version: '0'
94
94
  requirements: []
95
95
  rubyforge_project:
96
- rubygems_version: 2.7.6
96
+ rubygems_version: 2.7.3
97
97
  signing_key:
98
98
  specification_version: 4
99
99
  summary: Creates representations of your model data