creatable 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/creatable/class_methods.rb +4 -4
- data/lib/creatable/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: 59d37012a5526e8a8232a22ce8a4a3afd95c8a74
|
4
|
+
data.tar.gz: e65bb86091d43dfd8b1926ca4f8b5ba3ab30d6b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c7fc8764f34606beaaa4bf388156a94f7c0b239f5daffd8913fb066c4eca6c0cd1a10141c488cf38f4a9c4b515f01a4755ebd130e3278cea4b6898ee3ff0014
|
7
|
+
data.tar.gz: 61e9d37eb7cc3b7689313d1c3a990387b1951d11a8f35d1b64b9f9fb7a541d9b591c32ce41831c67d4ad274878e9c945805b87ee1d34eead9f64dafcf3222714
|
@@ -41,20 +41,20 @@ module Creatable
|
|
41
41
|
# @return [Object] Newly created object
|
42
42
|
def create(args = {})
|
43
43
|
object = new
|
44
|
-
# names = attributes.map { |e| e[:name].to_sym }
|
45
44
|
|
46
45
|
attributes.each do |a|
|
46
|
+
next unless args.keys.include? a[:name].to_sym
|
47
|
+
|
47
48
|
value = args[a[:name].to_sym]
|
48
|
-
next unless value
|
49
49
|
|
50
50
|
if a[:block]
|
51
|
-
a[:block].call object
|
51
|
+
a[:block].call object, value
|
52
52
|
else
|
53
53
|
object.instance_variable_set "@#{a[:name]}".to_sym, value
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
yield object if block_given?
|
57
|
+
yield object, args if block_given?
|
58
58
|
object
|
59
59
|
end
|
60
60
|
|
data/lib/creatable/version.rb
CHANGED