husky 0.4.5 → 0.4.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: daa68347b763a47be4743e0a00dec3dbe1f5028b
4
- data.tar.gz: 51dd870b777796468ac53c1d912ba20c403b02cc
3
+ metadata.gz: fb19f500859b313b1c459a2d1ecfe3769f362ebb
4
+ data.tar.gz: 2a798c85ca7c3b4774057ec8c97eebda794bb217
5
5
  SHA512:
6
- metadata.gz: 3d93c228b45f681485dc4796f6a2d77900d510a02b50051a3d5dc104cd1f522ebbafe6aebcda7d892557cc27a67dee7b0cbebf58ee4866b0b966432477137c8d
7
- data.tar.gz: a8b5b5e9986b4562eedab03d80a095bb8f9d69252ca88120a958dfee1609cbec35bbabefaac599ecb9e699e2111b7941a9bacbbc84292365c159cd7b01124866
6
+ metadata.gz: c142a982c6338786ce54b79cacc99f98f24cb37f89d6288f3170f180d7ffe8b015e978bd63fec4e4d954f044c42065bcf246edf41264b4750af524d486a8aff0
7
+ data.tar.gz: ebf131b7f9997e329e5befe42b115ac1a86e7cae019131c29aeec59b7f4698ac3e5e64be8f4c14c70ff2632bea27392d26fb3e1f3e88bafb21ffd9e0f5fd12f9
data/lib/husky/entity.rb CHANGED
@@ -10,46 +10,32 @@ module Husky
10
10
  items.map { |item| new(item) }
11
11
  end
12
12
 
13
- def new_from_hash(hash)
14
- raise hash_error(hash) unless hash.is_a? Hash
13
+ def new(*args, &block)
15
14
  instance = allocate
16
- instance.initialize_from_hash(hash)
15
+ instance.initialize(*args, &block)
17
16
  instance
18
17
  end
19
18
 
20
- def new_basic
21
- instance = allocate
22
- instance.initialize_basic
23
- instance
24
- end
25
-
26
- private
27
-
28
- def hash_error(hash)
29
- "Entity#initialize_from_hash expects a hash as an argument, and you provided a #{hash.class.name} (#=> #{hash})."
30
- end
31
-
32
19
  end
33
20
 
34
- attr_reader :object
35
-
36
- def initialize(object)
37
- @object = object
38
- super
39
- end
21
+ attr_reader :data
40
22
 
41
- def initialize_basic
42
- end
43
-
44
- def initialize_from_hash(post_data)
45
- post_data.each_pair do |key, value|
46
- instance_variable_set("@#{key}", value)
47
- end
23
+ def initialize(data = nil)
24
+ if data.nil?
25
+ # do nothing
26
+ elsif data.is_a? Hash
27
+ post_data.each_pair do |key, value|
28
+ instance_variable_set("@#{key}", value)
29
+ end
48
30
 
49
- post_data.each_pair do |key, value|
50
- self.class.send(:define_method, key) do
51
- instance_variable_get("@#{key}")
31
+ post_data.each_pair do |key, value|
32
+ self.class.send(:define_method, key) do
33
+ instance_variable_get("@#{key}")
34
+ end
52
35
  end
36
+ else
37
+ @data = data
38
+ super
53
39
  end
54
40
  end
55
41
 
data/lib/husky/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Husky
2
- VERSION = "0.4.5"
2
+ VERSION = "0.4.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: husky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Fiser