schema-model 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/schema/arrays.rb +20 -0
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e57c8c78613d7ee20ab7f3e6a47cada9bdead12040f43d54932bcda82f0d6935
4
- data.tar.gz: d16c1a6a36b4ba287afeb2c7bd961a26475dcdffa7be46edca5f1dce85ea63dd
3
+ metadata.gz: ac8d34b4f4d5952110866c557221814712384996a670fd99cffd215d5c3c8c30
4
+ data.tar.gz: c3d2d96927c520546921ef1b407597141234cd31755f97766f5da3ccab2a8c2a
5
5
  SHA512:
6
- metadata.gz: cb6bca0570036457fea00cd3f09bd1775564a71844442cd13d6ed2ff9daac848b92e84c652205de897a68c7cf587c676805210edef0ff1a4aa5e9d8667c95a3c
7
- data.tar.gz: 636b52ac448af439b79a9f64132fd85509433a6f65b426627a1f06930c498f2ea9da89353a9294a078142ebae1213468a70fbfe28a5f9bd8bbe0d4c2301486a2
6
+ metadata.gz: cf04def96de8e9c386715936878c1eb38fdd4b730bf3abddd2693a9d4e1203b4e33708edb0edf0883115913b5e140cdbbb4f79b0413a1cd54e45a871cb9c562b
7
+ data.tar.gz: ef527623d46265a06dbd499cff99c68b06b2e7892906a314567769852c2e2723c245b897e415728a3909e6d2455da21b21f9971b5e065d4f8065e6a2079e09cd
data/lib/schema/arrays.rb CHANGED
@@ -30,6 +30,26 @@ module Schema
30
30
  end
31
31
  data
32
32
  end
33
+
34
+ def to_headers(prefix = nil)
35
+ headers = []
36
+ schema.each do |_, field_options|
37
+ next if field_options[:alias_of]
38
+
39
+ headers <<
40
+ case field_options[:type]
41
+ when :has_one
42
+ const_get(field_options[:class_name]).to_headers(prefix.to_s + field_options[:key] + '.')
43
+ when :has_many
44
+ field_options[:size].times.map do |i|
45
+ const_get(field_options[:class_name]).to_headers(prefix.to_s + field_options[:key] + "[#{i +1}].")
46
+ end
47
+ else
48
+ prefix.to_s + field_options[:key]
49
+ end
50
+ end
51
+ headers.flatten
52
+ end
33
53
  end
34
54
 
35
55
  def to_a
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Doug Youch