parametric 0.2.7 → 0.2.8

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: 63dc92f4d7d45a1233ee42749f2a6511dfe0de3efa8fbc2f7fc2dd54e2832f70
4
- data.tar.gz: c2540792da112e082f610af8801a3f3609f1baee808971cf46ae1c1b0fccb9fc
3
+ metadata.gz: ef9d011c06f718caa4de95a60589cd858f693a98085a1962c8882e9213effd26
4
+ data.tar.gz: f759c6f6d051935a36d6a080b15602b628e4967b9b052d9ec3c5f912bf5a9b2e
5
5
  SHA512:
6
- metadata.gz: 5acd3bb1c560f340f42b82612adf14e8696293c1f053407ee67cdfba991a9745c6c5db770fe499c0a87b94e118e1f13c442d4063d9ffa2ee63a10c358c796573
7
- data.tar.gz: 1c56887e85b884dad8211b27faf748b3be1352eda48b15a19c76160e81f3cc359cc3f1cdcc4c1462efdcf778c01ba51bda3bf5f74de5a412aed1c0a7e28168ce
6
+ metadata.gz: 8f4867518fb179f164983751d2d6143a324eff9a961b91618e02677c74fe8e596f9f8d48a25582e2955c339f8128565b9cfaee95ca73f3a128a6b5861c5638aa
7
+ data.tar.gz: 87c47b5d47339b543027cff38b2f3a8a343ff27342ddfd1611fe0953c5b3169dee3064ac014a865382eebea0a87caab554312539f279648be43c66651c3a18b0
@@ -44,11 +44,16 @@ module Parametric
44
44
  copy_into instance
45
45
  end
46
46
 
47
- def merge(other_schema)
48
- instance = self.class.new(options.merge(other_schema.options))
47
+ def merge(other_schema = nil, &block)
48
+ raise ArgumentError, '#merge takes either a schema instance or a block' if other_schema.nil? && !block_given?
49
49
 
50
- copy_into(instance)
51
- other_schema.copy_into(instance)
50
+ if other_schema
51
+ instance = self.class.new(options.merge(other_schema.options))
52
+ copy_into(instance)
53
+ other_schema.copy_into(instance)
54
+ else
55
+ merge(self.class.new(&block))
56
+ end
52
57
  end
53
58
 
54
59
  def copy_into(instance)
@@ -1,3 +1,3 @@
1
1
  module Parametric
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
data/spec/schema_spec.rb CHANGED
@@ -169,6 +169,17 @@ describe Parametric::Schema do
169
169
  expect(new_schema.fields[:title].meta_data[:type]).to eq :string
170
170
  expect(new_schema.fields[:price].meta_data[:type]).to eq :string
171
171
  end
172
+
173
+ it 'can merge from a block' do
174
+ new_schema = schema1.merge do
175
+ field(:price).policy(:string)
176
+ field(:description).policy(:string)
177
+ end
178
+
179
+ expect(schema1.fields[:price].meta_data[:type]).to eq :integer
180
+ expect(new_schema.fields[:title].meta_data[:type]).to eq :string
181
+ expect(new_schema.fields[:price].meta_data[:type]).to eq :string
182
+ end
172
183
  end
173
184
 
174
185
  context "with options" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parametric
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ismael Celis