recursive_struct 0.0.3 → 0.0.4

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTJiYTU0MjJjNTUzOTM3YmExOWI5MWE3MDdlMTc1NzVjMDM3OTE0ZQ==
4
+ MTg4ZDBlM2U1ZjhhZGFhNDU1MTY0YTc2YmRhYjM1YWIxMmNiYTI5Yg==
5
5
  data.tar.gz: !binary |-
6
- ZDVmZTI4M2NmN2M1MDNmMjI0NTJkMjdlOTE3NDliZWM5MGJhZTgyNg==
6
+ N2ViNDY2ZTE0YTcyNDUwZDhlMzk2ZjYzMzc2NjlmYmM0YjRmMDY3NQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OGZiMjA5NDQxOGFmZjM2YzBlMzM5ZWIxNzg2N2QxNGQzYzJjMzk3NjM0NTEw
10
- NzYyMmZjYzBiNWJiZmQ5YjA2MTQwYzczNDM0MDEzNjQ1OTNhZTQzY2VlZWM0
11
- MWE2NTlmYTlkNDMwZTA1OWYyOTE4MzA4YWVmMjMwMjllZDE5YTU=
9
+ YmQzNjJhODlmMTg4NDJiZDc1YjEzOWJhODdiMGFmNjk0Y2U4ZTUzOGUyMzBm
10
+ OTM0NDlkNWNiZjY5NzcxM2NkYjU1ZDM1MWYyMmYyYThmNzcyZDE1ZDhkMGMz
11
+ MDI2MjJlYzZhOTFmNWZmOTk4YTkzMzJlYTkyNjQ0Y2I5YTA3NmM=
12
12
  data.tar.gz: !binary |-
13
- NTM2NWJjY2M4NmY1OGUyZDlmN2JmNWM2Y2RlYzYzYTBmNmNkMzA0NzJkMjg5
14
- ZGNmYzk1NTgxYWQ5NzM2YjEyZTNmZGZjOGE4ZjlkYWYyYjYzNTgxZWMyMWE2
15
- MzA4YzcwMzkxNWQzNGQ1NmI3MzI2N2FmMTcwNTUxZGFkOGU0Y2Q=
13
+ OTM1ZDIxZGEwZmViZjA0NmU3Nzc4M2YxZTFhZTg4MGQ5MzU3MGM4YzI0Y2Y0
14
+ OTUzYzM1NzRkNzQ3YmFjZDM0ZGEwZDg2MmM1YjUzMWEyZjBkOGJjODZkNTUy
15
+ ZWY1MjFiZDFjYWQyZTE4YjdkYmJkNjdkNjE4ZjE3ZjM4NWM0ZWQ=
data/README.md CHANGED
@@ -21,15 +21,28 @@ Or install it yourself as:
21
21
  ## Usage
22
22
 
23
23
  Passing a hash into the initializer will create an open struct that has all nested getter and setter methods.
24
-
25
24
  ```
26
25
  hash = { a: { b: true }, c: false }
27
26
  struct = RecursiveStruct.new(hash}
28
- struct.a # #<RecursiveStruct b=true>
27
+ struct.a # #<RecursiveStruct @data={:b=>true}>
29
28
  struct.a.b # true
30
29
  struct.c # false
31
30
  ```
32
31
 
32
+ You can also create set any value on any method and it will automatically create the getter and setter.
33
+ ```
34
+ struct = RecursiveStruct.new
35
+ struct.a = true
36
+ struct.a # true
37
+ ```
38
+
39
+ If this value happens to be a hash, it will wrap it in a RecursiveStruct
40
+ ```
41
+ struct = RecursiveStruct.new
42
+ struct.a = { b: true }
43
+ struct a # #<RecursiveStruct @data={:b=>true}>
44
+ ```
45
+
33
46
  ## Contributing
34
47
 
35
48
  1. Fork it ( https://github.com/pboksz/recursive_struct/fork )
@@ -1,3 +1,3 @@
1
1
  class RecursiveStruct
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -22,5 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "bundler", "~> 1.7"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
  spec.add_development_dependency "pry", "~> 0"
25
- spec.add_development_dependency "rspec", "~> 2"
25
+ spec.add_development_dependency "rspec", "~> 3"
26
26
  end
@@ -10,12 +10,12 @@ describe RecursiveStruct do
10
10
 
11
11
  describe 'hash exists' do
12
12
  let(:hash) { { one: true } }
13
- it { expect(subject.one).to be_true }
13
+ it { expect(subject.one).to be true }
14
14
  end
15
15
 
16
16
  describe 'nested hash' do
17
17
  let(:hash) { { one: { two: true } } }
18
- it { expect(subject.one.two).to be_true }
18
+ it { expect(subject.one.two).to be true }
19
19
  end
20
20
 
21
21
  describe 'hash with array' do
@@ -28,12 +28,12 @@ describe RecursiveStruct do
28
28
 
29
29
  describe 'nested setter' do
30
30
  before { subject.one.two = false }
31
- it { expect(subject.one.two).to be_false }
31
+ it { expect(subject.one.two).to be false }
32
32
  end
33
33
 
34
34
  describe 'top level setter' do
35
35
  before { subject.one = false }
36
- it { expect(subject.one).to be_false }
36
+ it { expect(subject.one).to be false }
37
37
  end
38
38
 
39
39
  describe 'setting a hash' do
@@ -51,7 +51,7 @@ describe RecursiveStruct do
51
51
  describe 'valid setter' do
52
52
  describe 'single value' do
53
53
  before { subject.one = true }
54
- it { expect(subject.one).to be_true }
54
+ it { expect(subject.one).to be true }
55
55
  end
56
56
 
57
57
  describe 'array value' do
@@ -61,7 +61,7 @@ describe RecursiveStruct do
61
61
 
62
62
  describe 'hash value' do
63
63
  before { subject.one = { two: true } }
64
- it { expect(subject.one.two).to be_true }
64
+ it { expect(subject.one.two).to eq true }
65
65
  end
66
66
  end
67
67
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recursive_struct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phillip Boksz
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '2'
61
+ version: '3'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: '2'
68
+ version: '3'
69
69
  description: A gem to create recursive structs similar to open struct.
70
70
  email:
71
71
  - pboksz@gmail.com