openstruct-from_hash.rb 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0105c584683b609b38620d26b039961b64633e57262a1deac1531e84b82c12c1
4
- data.tar.gz: f48a224c1ba643e9aa17030ae9eb13c413503bc2983c64a0c9a88edabfaf7d10
3
+ metadata.gz: cb3f2fdd1a4a83d3c5af39bdca949b282b4b0fae44783ddf6286d5caf6288c51
4
+ data.tar.gz: d7adb4baf9bfd95e355c6128523ecd4bb971f02d046b000df30a23d0fd8920c9
5
5
  SHA512:
6
- metadata.gz: 10f753dc7d2c7b0b8ca2e6a88f28d858709abf78571bf72f02e1c7994714b6626d6ae2bbfe3b5ebf1b32cbedd8c4a646e4db40c0661ae52e1e66855e99d9960b
7
- data.tar.gz: a97ccf8df386b4ddbdf3a74db61db06a31e4cfe7ea4d01b759fd5e056b920658a0fc585a28061fee600511d7023f2b926f625e0eb7792b534f45059745123d21
6
+ metadata.gz: a29c40221477bf32515ff9de498a0663f4bf78d3b7ccf8ab253ff2ad7faa41ca54682bb1f7a99989d3bfa7e841b91f3c8354d43475d371a5fffb417b349e5808
7
+ data.tar.gz: 4673e0b8a161fd0ac49e64aac5e7e068e1a08a136cc3224b95d061e38192525d7acbc347f6a19ff9d306908a31f92d25f98817760ccc208d08eb86ff11746a19
data/README.md CHANGED
@@ -16,13 +16,16 @@ constructor for the OpenStruct class that is apart of Ruby's standard library.
16
16
  ```ruby
17
17
  require 'ostruct'
18
18
  require 'openstruct-from_hash'
19
- obj = OpenStruct.from_hash(str: 'foo',
20
- ary: [{number: 20}],
21
- _hash: {float: 10.5}
19
+ obj = OpenStruct.from_hash(
20
+ str: 'foo',
21
+ ary: [{ number: 20 }],
22
+ person: { name: 'John', age: 21.5, friends: [{name: 'Amy'}] }
22
23
  )
23
- obj.str # => 'foo'
24
- obj.ary[0].number # => 20
25
- obj._hash.float # => 10.5
24
+ obj.str # => 'foo'
25
+ obj.ary[0].number # => 20
26
+ obj.person.name # => 'John'
27
+ obj.person.age # => 21.5
28
+ obj.person.friends[0].name # => 'Amy'
26
29
  ```
27
30
 
28
31
  ## <a id='install'>Install</a>
@@ -1,6 +1,6 @@
1
1
  class OpenStruct
2
2
  module FromHash
3
- VERSION = '0.3.0'.freeze
3
+ VERSION = '0.3.1'.freeze
4
4
 
5
5
  #
6
6
  # @example
@@ -6,12 +6,15 @@ require 'minitest/autorun'
6
6
 
7
7
  class OpenStructTest < Minitest::Test
8
8
  def test_from_hash_1
9
- obj = OpenStruct.from_hash(str: 'foo',
10
- ary: [{ number: 20 }, BasicObject],
11
- _hash: { float: 10.5 })
9
+ obj = OpenStruct.from_hash(
10
+ str: 'foo',
11
+ ary: [{ number: 20 }, BasicObject],
12
+ person: { name: 'John', friends: [{ name: 'Amy' }] }
13
+ )
12
14
  assert_equal 'foo', obj.str
13
15
  assert_equal 20, obj.ary[0].number
14
16
  assert BasicObject === obj.ary[1]
15
- assert_equal 10.5, obj._hash.float
17
+ assert_equal 'John', obj.person.name
18
+ assert_equal 'Amy', obj.person.friends[0].name
16
19
  end
17
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstruct-from_hash.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Gleeson