datastruct 0.0.0 → 0.0.1

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 +6 -0
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc2efcd0a11b90fdfd9e8d1ebfb5496fa2a80888
4
- data.tar.gz: ee44790d4e784c8d779f5ebe0517a1d78a39dac5
3
+ metadata.gz: 57e70ec82acf44e578a4c2fe14b3a66a57ab7c35
4
+ data.tar.gz: 20204bd8ec7ffa5b6086af783a661c01e4bc5df8
5
5
  SHA512:
6
- metadata.gz: 69ecf1c5bcd286128f57ed7d251a90432a02a6f0aad0469a36b22d67964f0800ef988e52087c497b5558893ea8d26fd7a8ec4f6795ac7382def5ff8043c7e449
7
- data.tar.gz: 12efa716b186c329e22d000c2c0bd0b6fad444bfac269df34749df19612778e4bc172a8f3727ca934b9704ec65c2844d1d843375bc0803e316490baeff13a5e7
6
+ metadata.gz: c7558ce5f0f399cc4d9b42ec3058360b6256849f3839f14fd720910882fd1a061cf11f56d84bf2e7ce914b41281d4ae2a836b0a02941a0bb30da7c9b166dea84
7
+ data.tar.gz: 5cb2b470af3ea6d969b7275e45ebabe674b1ed9ba432eff25a19639a35c079a9ddbd0c9dc81e0153d6783be0ab1334c93d44e0bb920783c5f66170fad45382e5
@@ -24,6 +24,8 @@ class DataStruct
24
24
  # A more ideomatic way of calling +new(**hash)+
25
25
  #
26
26
  def self.from_hash(hash)
27
+ hash = symbol_keys(hash)
28
+
27
29
  self.new(**hash)
28
30
  end
29
31
 
@@ -186,6 +188,10 @@ class DataStruct
186
188
 
187
189
  private
188
190
 
191
+ def self.symbol_keys(hash)
192
+ Hash[hash.each_pair.map { |x| [x[0].to_sym, x[1]] }]
193
+ end
194
+
189
195
  ##
190
196
  # This makes the struct accept the defined properties as instance methods
191
197
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datastruct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Sandven
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-05 00:00:00.000000000 Z
11
+ date: 2015-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake