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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/datastruct.rb +10 -5
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26a35334c97bcd236abcfd16d232c88751d4f0ac
4
- data.tar.gz: d85e97c5809da78bb5ed13835b74f77b125696a8
3
+ metadata.gz: 4cf29d068130c55911eddcb1c3ccc1070b9f4c19
4
+ data.tar.gz: 5c0e6c2831c57452a376ddc0dafe632ea7ef0292
5
5
  SHA512:
6
- metadata.gz: 4f04fd4badc2ee0c964d48f99e1addd7ab45d8a8e58c9d0740ea3bfe903463d6d1fa38a20e412ce9a9322efd86bd14f060d8bc49a9474a1f1ff4f21499b7d679
7
- data.tar.gz: 9f939ad5e9156b0a72db02f299bb84cc5dd2c57c6e59923e0227492c5d25f17d01dcc164a7c3422d9a665296bdb5f5d3002bffc6a01ea91199f1254fc8305ae7
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.2"
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datastruct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Sandven