ethos 0.2.0.beta3 → 0.2.0.beta4

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: 8ee0d4eb3b806134f48dc44e904f82a3307fa385
4
- data.tar.gz: 94331cd4a93fa367f59038c11e4e86812c65f19c
3
+ metadata.gz: be315115b1c5686fe19970b30ad0ab222745981d
4
+ data.tar.gz: 7aebb378346adbb1a0aa2c46fa1f9c275a520cd7
5
5
  SHA512:
6
- metadata.gz: 286ee730bd33ad3efd7ddea9c572252a4e998a9b5558a77ee74e9d78c1fc228e7a6821208ed86d7396b671c656b105fb8b3457bdb7b9c1375a667f2a509cee66
7
- data.tar.gz: f26d4be1f6442a052c940edc1c0b0ea22465aab0ef3825f4e3d306c6490a32b3748b335abc121fa4669f7b5cd43d6ed079ad84d292723967a7d95d19e2a38283
6
+ metadata.gz: a87b14e54f833fa83bdd67e1d06545db7a76feaea8f8e0528a6030bc86144b96f629ea3784bae3a37af3c5ad51658746f31555b19b72bf72d32ac6b08334e5ce
7
+ data.tar.gz: 6cd180a3fb63901b7c01d7590ed6c067ea5fa3f554982d96d663cd26a87f6fc8e9fcf081b59b164b20cb47f0c0ad95579c058fb89f60379a467dfbe54eba9806
@@ -17,9 +17,16 @@ module Ethos
17
17
  def initialize(schema, values: {})
18
18
  @_schema = schema
19
19
 
20
+ schema.defaults.each do |key, value|
21
+ initial[key] = value
22
+ current[key] = value
23
+ end
24
+
20
25
  values.each do |key, value|
21
26
  key = key.to_sym
22
27
 
28
+ next unless schema.defined? key
29
+
23
30
  initial[key] = value
24
31
  current[key] = value
25
32
  end
@@ -29,10 +29,7 @@ module Ethos
29
29
  end
30
30
 
31
31
  def initialize(values = {})
32
- schema = self.class.schema
33
- values = values.merge schema.defaults
34
-
35
- @_attributes = Ethos::Attributes.new schema, values: values
32
+ @_attributes = Ethos::Attributes.new self.class.schema, values: values
36
33
 
37
34
  super()
38
35
  end
@@ -16,5 +16,9 @@ module Ethos
16
16
 
17
17
  defaults[key] = default if default
18
18
  end
19
+
20
+ def defined?(key)
21
+ attributes.key? key
22
+ end
19
23
  end
20
24
  end
@@ -1,3 +1,3 @@
1
1
  module Ethos
2
- VERSION = '0.2.0.beta3'
2
+ VERSION = '0.2.0.beta4'
3
3
  end
@@ -42,6 +42,12 @@ scope do
42
42
 
43
43
  asserts(entity.value) == 1
44
44
  end
45
+
46
+ spec do
47
+ entity = Entity.new value: 2
48
+
49
+ asserts(entity.value) == 2
50
+ end
45
51
  end
46
52
 
47
53
  scope do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ethos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.beta3
4
+ version: 0.2.0.beta4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erol Fornoles