datastruct 0.0.2 → 0.0.3
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/datastruct.rb +10 -5
- 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: 4cf29d068130c55911eddcb1c3ccc1070b9f4c19
|
4
|
+
data.tar.gz: 5c0e6c2831c57452a376ddc0dafe632ea7ef0292
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f632b3e10d78b5348d6639475413d55ef786aa6fcec34aa047ea922f5fb2e7223648a00258c0db0b66eda9ad847f651646ea32c298fe008226600cca375870c
|
7
|
+
data.tar.gz: cb085d1a32249b4bee81056353ccfc2046d0958fbe15d42f2086d79b39ca8d367baec8f4df4f9812accc845532d71c763b97ac309dba930286616cb6feebfc3e
|
data/lib/datastruct.rb
CHANGED
@@ -11,7 +11,16 @@ def DataStruct(*props, &block)
|
|
11
11
|
end
|
12
12
|
|
13
13
|
class DataStruct
|
14
|
-
VERSION = "0.0.
|
14
|
+
VERSION = "0.0.3"
|
15
|
+
|
16
|
+
def self.new(*args, **kwargs, &block)
|
17
|
+
instance = allocate()
|
18
|
+
instance.instance_variable_set(:@data, {})
|
19
|
+
|
20
|
+
instance.send(:initialize, *args, **kwargs, &block)
|
21
|
+
|
22
|
+
return instance
|
23
|
+
end
|
15
24
|
|
16
25
|
##
|
17
26
|
# A more ideomatic way of calling +new(*array)+
|
@@ -30,8 +39,6 @@ class DataStruct
|
|
30
39
|
end
|
31
40
|
|
32
41
|
def initialize(*args, **kwargs)
|
33
|
-
@data ||= {}
|
34
|
-
|
35
42
|
self.update(*args)
|
36
43
|
self.update(**kwargs)
|
37
44
|
end
|
@@ -183,8 +190,6 @@ class DataStruct
|
|
183
190
|
# @return nil
|
184
191
|
#
|
185
192
|
def update(*args, **kwargs)
|
186
|
-
@data ||= {}
|
187
|
-
|
188
193
|
if args.length > self.class::PROPERTIES.length
|
189
194
|
x = args.length
|
190
195
|
y = self.class::PROPERTIES.length
|