clavatar 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/clavatar.rb +6 -5
- data/lib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bf8acd0bef190c30df6f83601381a111eb9995b
|
4
|
+
data.tar.gz: b39b837348b64a8830e81fdb1592f397e91ce4d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e0d642c1a5e629c2452028c74b4ddd87447a11c61ddf0b8d1b23006df762c8fe3019391a7609be792d37f94bc470741f803d117bf87da53819aa878c005605f
|
7
|
+
data.tar.gz: 49fe7d4193bf09212b0da64c6271216f05dbe1cbe995bbea453b48db6ede0249eec54da3fd6a152be121b30aefd7ff0fb42d35f8c594ced31fb62683be0ddfc7
|
data/lib/clavatar.rb
CHANGED
@@ -3,11 +3,12 @@ require 'ostruct'
|
|
3
3
|
# Clavatar module
|
4
4
|
module Clavatar
|
5
5
|
def self.cast(hash, klass, example)
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
name_space = klass.respond_to?(:parent) ? klass.parent : Object
|
7
|
+
klass_name = "#{klass.name.split('::').last}Avatar"
|
8
|
+
if name_space.const_defined? klass_name
|
9
|
+
klass = name_space.const_get klass_name
|
9
10
|
else
|
10
|
-
klass =
|
11
|
+
klass = name_space.const_set klass_name, Class.new(klass)
|
11
12
|
end
|
12
13
|
|
13
14
|
args = {}
|
@@ -21,7 +22,7 @@ module Clavatar
|
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
|
-
instance = klass.new args
|
25
|
+
instance = klass.new args.merge(hash)
|
25
26
|
accessible_attr.each do |attr|
|
26
27
|
instance.send("#{attr}=", hash[attr])
|
27
28
|
end
|
data/lib/version.rb
CHANGED