nested_struct 1.0.1 → 1.0.2

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
  SHA1:
3
- metadata.gz: bc9126c95e9c21a8a9ce36a1cda922227597fa64
4
- data.tar.gz: 5f55463da5e91facccde403207ab6eaf12f5a950
3
+ metadata.gz: 4e195b1ddbcb294d2baabdd49659735e5e374501
4
+ data.tar.gz: 3180a3311178af1a40ec00fec1e3118c4fbeae8d
5
5
  SHA512:
6
- metadata.gz: 4627df529f9fc9be213e4a2540b4d288866bef70d5ad7e6a56ee04739b64cdb541d1e6d552f2592531a0d7e450ea4cb90300dab29a7ca88913a162cb345d80f9
7
- data.tar.gz: f60ddb0144586dddcc56f677621b1991e3e9f110ceeaa9eea4b617cec91c14c60accc17d04bcbd5f2ca673aa51d2af67f656f3ad1efbfbfa6e970c1c670a88fb
6
+ metadata.gz: 801f71525350455e645970929354fa7bbb8238e933400763c23a4e23ca0c4d8bd8cea6956ab4ef571843346668c98d121c2db83ddc61732ff12912da0cadf990
7
+ data.tar.gz: d1eee041969b9d18afc631b840a92b5ab9c6729c0fd7180272f5917c07fa73b2e9ebb5eba42a39502806946bb9b145e0855a3691ba9aa7f72af3cdff45bbbd9e
@@ -1,20 +1,25 @@
1
1
  module NestedStruct
2
2
  module Interface
3
3
  def self.included(base)
4
- base.class_eval do
5
- @field_names ||= []
6
- @fields ||= []
4
+ base.extend(ClassMethods)
5
+ end
6
+
7
+ module ClassMethods
8
+ attr_reader :field_names, :fields
7
9
 
8
- class << self
9
- attr_reader :field_names, :fields
10
+ def field(name, coercer_expression = nil)
11
+ if superclass.ancestors.include?(NestedStruct::Interface)
12
+ @field_names ||= superclass.field_names.dup
13
+ @fields ||= superclass.fields.dup
14
+ else
15
+ @field_names ||= []
16
+ @fields ||= []
17
+ end
10
18
 
11
- def field(name, coercer_expression = nil)
12
- if !field_names.include?(name)
13
- @field_names << name
14
- @fields << Field.new(name, coercer_expression)
15
- attr_accessor(name)
16
- end
17
- end
19
+ if !field_names.include?(name)
20
+ @field_names << name
21
+ @fields << Field.new(name, coercer_expression)
22
+ attr_accessor(name)
18
23
  end
19
24
  end
20
25
  end
@@ -1,3 +1,3 @@
1
1
  module NestedStruct
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nested_struct
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krzysztof Buszewicz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-15 00:00:00.000000000 Z
11
+ date: 2018-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  version: '0'
100
100
  requirements: []
101
101
  rubyforge_project:
102
- rubygems_version: 2.5.1
102
+ rubygems_version: 2.6.8
103
103
  signing_key:
104
104
  specification_version: 4
105
105
  summary: Compose nested structs from hash/array structures.