immutable_struct_ex 0.2.3 → 0.3.0

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: 1a0a34457a9487fc3f303f5605d59b4b16e31621f7d3a3fdeb6ea3c2cb3df0bb
4
- data.tar.gz: d7e39e8460fac3985e54929ef0ceda6dba990468daaceb666094149a784fbd06
3
+ metadata.gz: aa4a48dbdce57780e5b5d4070af7cc8c23178bfce3ad7fe7aa7f4ccb5c8c57bd
4
+ data.tar.gz: '093d4b2a568379b9f3a60c408e8b193c3529b08747a187a0c89740e3b5d18d10'
5
5
  SHA512:
6
- metadata.gz: 9d2058c398d2083f608ad57b1b54f9c4a0379a95645a36479bdb02007ef0acfe0560d58576c47bc754dad21830876f027329f163f1326dd3139700967c8aaa0d
7
- data.tar.gz: c222c628b6b35c8ef5598c644460246b4f015e754bf5d65cdc3b3dc045e56a0a4fcf0efc5224f2c626ea0d8c41c65eefcde462f35b179ecd4954581f4dc28c3d
6
+ metadata.gz: 0c0ac39ffb5460f9d7a02495758285d2cb6407d985f8bb1c52eff686e5e015bc3a28e5bc33a7a091507cb93a40348eebebe563cc6aaf49d0d65b7e54f6b33c2d
7
+ data.tar.gz: e3bbb35209074a059fd695aec4da31d60731929633c88e268bb643bdd0fd433530cb3f44bb57377e478a571cfaeae5a87cad0fd44084b2bb94b11270f50c4ac2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 0.3.0
2
+ * Changes
3
+ * Update README.md file with the correct gem name.
4
+
1
5
  ### 0.2.3
2
6
  * Bug fix
3
7
  * Fix bug in specs that failed to add criteria for passing tests (e.g. ".to eq true/false") so tests could not fail.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- immutable_struct_ex (0.2.3)
4
+ immutable_struct_ex (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -86,4 +86,4 @@ DEPENDENCIES
86
86
  simplecov (~> 0.21.2)
87
87
 
88
88
  BUNDLED WITH
89
- 2.3.20
89
+ 2.3.22
data/README.md CHANGED
@@ -8,9 +8,9 @@
8
8
 
9
9
  [![License](http://img.shields.io/badge/license-MIT-yellowgreen.svg)](#license)
10
10
 
11
- # ImmutableStructEx
11
+ # immutable_struct_ex
12
12
 
13
- _ImmutableStructEx_ is yet another immutable struct. What makes ImmutableStructEx different, is that it allows you to create immutable structs in one step _by default_. In other words, other immutable struct gems force you to first define the struct, then instantiate the struct object; or, define the struct and instantiate the struct object via chaining. For example:
13
+ immutable_struct_ex is yet another immutable struct. What makes immutable_struct_ex different, is that it allows you to create immutable structs in one step _by default_. In other words, other immutable struct gems force you to first define the struct, then instantiate the struct object; or, define the struct and instantiate the struct object via chaining. For example:
14
14
 
15
15
  ## Other Immutable Structs
16
16
 
@@ -24,31 +24,38 @@ some_immutable_struct = SomeImmutableStruct.new(:first, :last, :phone)
24
24
  .new(first: 'John', last: 'Doe', phone: '(201) 230-7281')
25
25
  ```
26
26
 
27
- ## ImmutableStructEx
28
- ImmutableStructEx allows you do this in one step:
27
+ ## immutable_struct_ex
28
+ immutable_struct_ex allows you to instantiate and initialize the object _in one step:_
29
29
 
30
30
  ```ruby
31
31
  immutable_struct_ex = ImmutableStructEx.new(first: 'John', last: 'Doe', phone: '(201) 230-7281')
32
+
32
33
  immutable_struct_ex.first
33
34
  #=> 'John'
35
+
34
36
  immutable_struct_ex[:first]
35
37
  #=> 'John'
38
+
36
39
  immutable_struct_ex.last
37
40
  #=> 'Doe'
41
+
38
42
  immutable_struct_ex.phone
39
43
  #=> '(201) 230-7281'
40
44
  ```
41
45
  ### Immutable
42
- Like other immutable structs, ImmutableStructEx also removes methods that change the state of the object:
46
+ Like other immutable structs, immutable_struct_ex also removes methods that change the state of the object, making it _immutable:_
47
+
43
48
  ```ruby
44
49
  immutable_struct_ex.first = 'Joe'
45
50
  #=> NoMethodError: undefined method `first='...
51
+
46
52
  immutable_struct_ex[:first] = 'Joe'
47
53
  #=> NoMethodError: undefined method `[]='...
48
54
  ```
49
55
 
50
56
  ### Blocks
51
- Also, not unlike other immutable structs, ImmutableStructEx also allows you to pass a block:
57
+ Also, not unlike other immutable structs, immutable_struct_ex also allows you to pass a block:
58
+
52
59
  ```ruby
53
60
  # With a block
54
61
  immutable_struct_ex = ImmutableStructEx.new(first: 'John', last: 'Doe', phone: '(201) 230-7281') do
@@ -56,14 +63,22 @@ immutable_struct_ex = ImmutableStructEx.new(first: 'John', last: 'Doe', phone: '
56
63
  first == 'John'
57
64
  end
58
65
  end
66
+
59
67
  immutable_struct_ex.john?
60
68
  #=> true
61
69
  ```
62
70
 
63
71
  ### Other Examples
72
+ Get creative. Below is an example of an immutable struct that provides _redaction_:
73
+
64
74
  ```ruby
65
75
  # Redactable, immutable struct
66
- user = { username: 'jdoe', password: 'p@55w0rD', ssn: '123-70-9182' }
76
+ user = {
77
+ username: 'jdoe',
78
+ password: 'p@55w0rD',
79
+ ssn: '123-70-9182'
80
+ }
81
+
67
82
  immutable_struct_ex = ImmutableStructEx.new(**user) do
68
83
  REDACT = %i(password ssn).freeze
69
84
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ImmutableStructEx
4
- VERSION = '0.2.3'
4
+ VERSION = '0.3.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: immutable_struct_ex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gene M. Angelo, Jr.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-24 00:00:00.000000000 Z
11
+ date: 2022-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -212,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
212
  - !ruby/object:Gem::Version
213
213
  version: '0'
214
214
  requirements: []
215
- rubygems_version: 3.2.15
215
+ rubygems_version: 3.3.22
216
216
  signing_key:
217
217
  specification_version: 4
218
218
  summary: Creates an immutable struct in one step.