creatable 2.2.0 → 2.2.1

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: e6b42abcff609998d39ef809a52187796c820a88
4
- data.tar.gz: fa805820fcee26be7b4febe18422cf47f33c0140
3
+ metadata.gz: 59d37012a5526e8a8232a22ce8a4a3afd95c8a74
4
+ data.tar.gz: e65bb86091d43dfd8b1926ca4f8b5ba3ab30d6b8
5
5
  SHA512:
6
- metadata.gz: f64fc80434e4a78a55b934b44d3d321c16315a3ddf5a8a592884d191a70592a271097f5b9e86e769d9fb4e98f58bc0bf7996c2fd9485f987189025fe50fd58bf
7
- data.tar.gz: 8b77d760f5e4cad59d6f78ebecaccfc7883ce6bb6069447370d07d044544df7b0400d8981ec54a41a01017df788a6a1b65e61cf7042819ceb1e8f7f10cdf08e9
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
 
@@ -1,3 +1,3 @@
1
1
  module Creatable
2
- VERSION = '2.2.0'.freeze # VERSION
2
+ VERSION = '2.2.1'.freeze # VERSION
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: creatable
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernie Brodeur