ethos 0.2.0.beta6 → 0.2.0.beta7

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: a5276ca4d23c477202536ce281058bbf651ee991
4
- data.tar.gz: 8b8b8b06029d531098f59b7a35c3fc9a210f0af9
3
+ metadata.gz: 9335ed3374ed7cc4b506193942250129d94a898e
4
+ data.tar.gz: 9bb3226db9720f6307398e68fbf395d2bed69dde
5
5
  SHA512:
6
- metadata.gz: 6e444f7539a1d2edc76945a986ac9515584d11de2634c9e4bd98b989ff252344de784cb73c55b832718438dcee7ad64e1517b6bde64a948dd4827731d75d3326
7
- data.tar.gz: 6baf42220b5190238dd5ee074c56ca508de73c4236df57d37f9d84b14f94e877085847a953612317d659a7e35aade4b20b3c07af96ebc62bd365a4da57b0a395
6
+ metadata.gz: ec69f3cd21d22b4d082c5f5ad1c8823a5cfb5aac30fa5831d7b3ae4659ad0e98f7bf29d44239fe3ce12e8c42c14916bf9df803810646891b4e19726d685c3410
7
+ data.tar.gz: 5766fca046926bf658ac8444c91bd6ee24dc38e89f1d1f21d904032bbe47c5370d8a42a3b44c0bddc028df62de4f557ef79fc80acb925d3605dd6c5ae9f813f2
@@ -13,6 +13,8 @@ module Ethos
13
13
  def self.cast(value, type)
14
14
  return value if value.nil?
15
15
 
16
+ type = Module.const_get type if type.is_a? String
17
+
16
18
  return value if value.is_a? type
17
19
 
18
20
  return CASTS[type][value] if CASTS.key? type
@@ -1,3 +1,3 @@
1
1
  module Ethos
2
- VERSION = '0.2.0.beta6'
2
+ VERSION = '0.2.0.beta7'
3
3
  end
@@ -90,6 +90,13 @@ scope '.cast' do
90
90
  asserts(result.value) == expected.value
91
91
  end
92
92
 
93
+ spec 'casts to an instance of a type specified by a string' do
94
+ expected = 1.0
95
+ result = Ethos::Type.cast '1', 'Float'
96
+
97
+ asserts(result) == expected
98
+ end
99
+
93
100
  spec 'casts a nil' do
94
101
  class Entity
95
102
  prepend Ethos::Entity
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.beta6
4
+ version: 0.2.0.beta7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erol Fornoles