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 +4 -4
- data/lib/nested_struct/interface.rb +17 -12
- data/lib/nested_struct/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e195b1ddbcb294d2baabdd49659735e5e374501
|
4
|
+
data.tar.gz: 3180a3311178af1a40ec00fec1e3118c4fbeae8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
5
|
-
|
6
|
-
|
4
|
+
base.extend(ClassMethods)
|
5
|
+
end
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
attr_reader :field_names, :fields
|
7
9
|
|
8
|
-
|
9
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
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.
|
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-
|
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.
|
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.
|