ethos 0.2.0.beta15 → 0.2.0.beta16

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: 4004a378fc014fe0520a7aad3c6e1f7a54f6c20d
4
- data.tar.gz: bc94babcb920eb31b9b0688e67d97070dff813fd
3
+ metadata.gz: 30021531347aa3283fa03db99b755239d3a847cf
4
+ data.tar.gz: 1274e0cd1da645983056901612dcd7f5d98494fe
5
5
  SHA512:
6
- metadata.gz: d6f5ffdff1f91775a6f790c8128fd755f334ceca215f654e481dc1a6c80ec9976f0212d6efb52e2aab5e70e449d737d504ef8afe0940c30d7281c5d9e1962732
7
- data.tar.gz: 550df24d7388d397c8e7b87ef3e57043568b570d05432490d13460ef3e4b50948b085ab3247272f3cdde31ceb64c332c8ca3a23d524231be4a45807f36470e1c
6
+ metadata.gz: 17c0daf1764105d5547db68b695cfeeb28ac45c37b59338ea8042ddb9b00925a17717cefef6959a298b4474e726fcd7b24fcfd1e66965a49eb173608bef55968
7
+ data.tar.gz: 263c37452568386b36c15659c7888bec2d9ee1430333b9d2dddaed4eed1f2cd75a0bd4cf60c8ff75ad7895c1eda5908f40d559f0c5f8ef86a9d84a7fb18be7ed
@@ -28,14 +28,20 @@ module Ethos
28
28
 
29
29
  def [](key)
30
30
  memoize key do
31
- type = schema.attributes[key][:type]
31
+ scheme = schema.attributes[key]
32
+ value = current[key]
32
33
 
33
- raw = current[key]
34
- raw = schema.attributes[key][:nothing] if raw.nil?
34
+ type = scheme[:type]
35
35
 
36
- value = Ethos::Type.cast raw, type
36
+ if value.nil?
37
+ nothing = scheme[:nothing]
37
38
 
38
- schema.attributes[key][:extensions].each do |extension|
39
+ value = nothing.is_a?(Proc) ? nothing.call : nothing
40
+ end
41
+
42
+ value = Ethos::Type.cast value, type
43
+
44
+ scheme[:extensions].each do |extension|
39
45
  value.instance_eval &extension
40
46
  end
41
47
 
@@ -1,3 +1,3 @@
1
1
  module Ethos
2
- VERSION = '0.2.0.beta15'
2
+ VERSION = '0.2.0.beta16'
3
3
  end
@@ -99,6 +99,34 @@ scope do
99
99
  end
100
100
  end
101
101
 
102
+ scope do
103
+ setup do
104
+ class Entity
105
+ prepend Ethos::Entity
106
+
107
+ attribute :value, Integer, nothing: -> { 1 }
108
+ end
109
+ end
110
+
111
+ spec do
112
+ entity = Entity.new
113
+
114
+ asserts(entity.value) == 1
115
+ end
116
+
117
+ spec do
118
+ entity = Entity.new value: nil
119
+
120
+ asserts(entity.value) == 1
121
+ end
122
+
123
+ spec do
124
+ entity = Entity.new value: 2
125
+
126
+ asserts(entity.value) == 2
127
+ end
128
+ end
129
+
102
130
  scope do
103
131
  setup do
104
132
  class Entity
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ethos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.beta15
4
+ version: 0.2.0.beta16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erol Fornoles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-30 00:00:00.000000000 Z
11
+ date: 2015-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  version: 1.3.1
114
114
  requirements: []
115
115
  rubyforge_project:
116
- rubygems_version: 2.4.6
116
+ rubygems_version: 2.4.5
117
117
  signing_key:
118
118
  specification_version: 4
119
119
  summary: Lightweight entity library for Ruby