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 +4 -4
- data/lib/ethos/attributes.rb +11 -5
- data/lib/ethos/version.rb +1 -1
- data/spec/ethos/entity.rb +28 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30021531347aa3283fa03db99b755239d3a847cf
|
4
|
+
data.tar.gz: 1274e0cd1da645983056901612dcd7f5d98494fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17c0daf1764105d5547db68b695cfeeb28ac45c37b59338ea8042ddb9b00925a17717cefef6959a298b4474e726fcd7b24fcfd1e66965a49eb173608bef55968
|
7
|
+
data.tar.gz: 263c37452568386b36c15659c7888bec2d9ee1430333b9d2dddaed4eed1f2cd75a0bd4cf60c8ff75ad7895c1eda5908f40d559f0c5f8ef86a9d84a7fb18be7ed
|
data/lib/ethos/attributes.rb
CHANGED
@@ -28,14 +28,20 @@ module Ethos
|
|
28
28
|
|
29
29
|
def [](key)
|
30
30
|
memoize key do
|
31
|
-
|
31
|
+
scheme = schema.attributes[key]
|
32
|
+
value = current[key]
|
32
33
|
|
33
|
-
|
34
|
-
raw = schema.attributes[key][:nothing] if raw.nil?
|
34
|
+
type = scheme[:type]
|
35
35
|
|
36
|
-
value
|
36
|
+
if value.nil?
|
37
|
+
nothing = scheme[:nothing]
|
37
38
|
|
38
|
-
|
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
|
|
data/lib/ethos/version.rb
CHANGED
data/spec/ethos/entity.rb
CHANGED
@@ -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.
|
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-
|
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.
|
116
|
+
rubygems_version: 2.4.5
|
117
117
|
signing_key:
|
118
118
|
specification_version: 4
|
119
119
|
summary: Lightweight entity library for Ruby
|