dry-data 0.4.1 → 0.4.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: 25b19951b05ff45b26a3b49697be290ca1d158e1
4
- data.tar.gz: e33200c58bb1e9cc283385f4ec17ee1b47892d8c
3
+ metadata.gz: 0d798aac2e4dd90dc419ed04f7366d04a5aae2a1
4
+ data.tar.gz: 35060cab0302057a57e3f098ec2842cb9824840d
5
5
  SHA512:
6
- metadata.gz: ebbc4fa62ef404c3f12af3d49ab7272a92de00400606aee3ca280ebfa0cae73191419c3f36e89730ba76848713d4a92dfb7555020fb6badfe25d8d3fbba2dc61
7
- data.tar.gz: 51acb033f6d282060d3170d7d9c029349af1a0da3574617d8129e9fe68c8d14664a041e9fd1b5ecfb86204311fe6883939509d03c88d4e35cc192fd721bbbeed
6
+ metadata.gz: b60ca79d4da30f0af580450b3ea05b4d2fc09cf45235f419ef38d7de4a0f0e87cb5640e925433d7aa5d6a6a3153447b7505f973e9460e23a529ded9903827893
7
+ data.tar.gz: d71b05244589161fbe4a464f11eeb56ed94b7a8408b4c29e6ad934231b998545e9b3fdf3ba4bbcc01c097763489c6c0a43571f7b91a14f831a63cb859494a9d5
@@ -1,12 +1,14 @@
1
- # v0.4.1 2015-12-11
1
+ # v0.4.2 2015-12-27
2
2
 
3
3
  ## Added
4
4
 
5
- * `Dry::Data::Struct#to_hash` with `to_h` as alias (solnic)
6
- * `Dry::Data::Struct#[]` for reading attribute values (solnic)
7
- * Ability to pass any class to hash schema assuming it has a corresponding type registered (solnic)
5
+ * Support for arrays in type compiler (solnic)
8
6
 
9
- [Compare v0.4.0...v0.4.1](https://github.com/dryrb/dry-data/compare/v0.4.0...v0.4.1)
7
+ ## Changed
8
+
9
+ * Array member uses type objects now rather than just their constructors (solnic)
10
+
11
+ [Compare v0.4.1...v0.4.2](https://github.com/dryrb/dry-data/compare/v0.4.1...v0.4.2)
10
12
 
11
13
  # v0.4.0 2015-12-11
12
14
 
@@ -34,6 +34,10 @@ module Dry
34
34
  registry['hash'].public_send(constructor, schema.map { |key| visit(key) }.reduce(:merge))
35
35
  end
36
36
 
37
+ def visit_array(node)
38
+ registry['array'].member(call(node))
39
+ end
40
+
37
41
  def visit_key(node)
38
42
  name, types = node
39
43
  { name => visit(types) }
@@ -3,16 +3,14 @@ module Dry
3
3
  class Type
4
4
  class Array < Type
5
5
  def self.constructor(array_constructor, member_constructor, input)
6
- array_constructor[input].map(&member_constructor)
6
+ array_constructor[input].map { |value| member_constructor[value] }
7
7
  end
8
8
 
9
9
  def member(type)
10
10
  member_constructor =
11
11
  case type
12
- when Type then type.constructor
13
- when Class then Data[type].constructor
14
- else
15
- raise ArgumentError, "+#{type}+ is an unsupported array member"
12
+ when String, Class then Data[type]
13
+ else type
16
14
  end
17
15
 
18
16
  array_constructor = self.class
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  module Data
3
- VERSION = '0.4.1'.freeze
3
+ VERSION = '0.4.2'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-data
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-11 00:00:00.000000000 Z
11
+ date: 2015-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thread_safe
@@ -202,9 +202,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
202
  version: '0'
203
203
  requirements: []
204
204
  rubyforge_project:
205
- rubygems_version: 2.4.5
205
+ rubygems_version: 2.4.5.1
206
206
  signing_key:
207
207
  specification_version: 4
208
208
  summary: Simple type-system for Ruby
209
209
  test_files: []
210
- has_rdoc: