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 +4 -4
- data/lib/husky/entity.rb +17 -31
- data/lib/husky/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: fb19f500859b313b1c459a2d1ecfe3769f362ebb
|
4
|
+
data.tar.gz: 2a798c85ca7c3b4774057ec8c97eebda794bb217
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
14
|
-
raise hash_error(hash) unless hash.is_a? Hash
|
13
|
+
def new(*args, &block)
|
15
14
|
instance = allocate
|
16
|
-
instance.
|
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 :
|
35
|
-
|
36
|
-
def initialize(object)
|
37
|
-
@object = object
|
38
|
-
super
|
39
|
-
end
|
21
|
+
attr_reader :data
|
40
22
|
|
41
|
-
def
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
50
|
-
|
51
|
-
|
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