thread_local_var_accessors 0.1.1 → 0.1.2

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: 1b6e9d88de11a15e80e03d531bbb506da4b962e057ee1e88f0eb56f79c0eca74
4
- data.tar.gz: 919b3b1100b7d8683317869cda3dbd87672ba6e30a0a86c565fffd0cefadcc99
3
+ metadata.gz: f567c363dc63194dc30aeae5d661ea14c871f9f64cc65ed3d2c2947447d1fc91
4
+ data.tar.gz: 30c3bc0763221a483de2370af6843c83b39ff6429f27f1b6ad796931fa9dae51
5
5
  SHA512:
6
- metadata.gz: 2c1c294e53542491de381e69ff49b9b68942f6d5dc06ef8256f954dbec8af9c23396a4fd995d10701017b790c51880c6928c451c4e521c0b7cef80233af50aba
7
- data.tar.gz: 740127f6247210b11f2ad478005eb459780afa6f50e451416b74a6ac35081d1ab818151b85bab786dd60031f71ee67cc01fc7b45423c454976f66834e000d0e0
6
+ metadata.gz: 59329574532e6730a71d3f44d011bedae930ee29a0b592f9ff8fbf7ed6d824a13cb65ab9f51edb40df372615c5975f459bd483fc467f5914af48f992a21f7cfc
7
+ data.tar.gz: 822c3f467f172562efdab7a38cc73063b42b8937f09d71ad01345c52d80fa69bc438a60067756386aa8d4d8ba74055513cd4303875a3784b13a5d07e3120adcc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- thread_local_var_accessors (0.1.1)
4
+ thread_local_var_accessors (0.1.2)
5
5
  concurrent-ruby
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -105,17 +105,30 @@ Then:
105
105
 
106
106
  ## Usage
107
107
 
108
- Use the class methods to declare instance getter and setter methods:
108
+ To use the class methods, they must be included into the current module or class, with:
109
109
 
110
- tlv_reader :name1
111
- tlv_writer :name2
112
- tlv_accessor :name3, :name4
110
+ class MyNewClass
111
+ include ThreadLocalVarAccessors
112
+ ...
113
+ end
114
+
115
+ With the include above, you can use the class methods to declare instance getter and setter methods:
116
+
117
+ class MyNewClass
118
+ include ThreadLocalVarAccessors
119
+
120
+ tlv_reader :name1
121
+ tlv_writer :name2
122
+ tlv_accessor :name3, :name4
123
+
124
+ end
113
125
 
114
126
  The above invocations:
127
+
115
128
  - create reader methods for `name1`, `name3`, and `name4`.
116
129
  - create writer methods for `name2`, `name3`, and `name4`.
117
130
 
118
- The writer methods accept a value as the second argument, or from the result of an associated block.
131
+ The writer methods accept a value as the second argument, or from the result of an optional, associated block.
119
132
 
120
133
  Note: to use the read-and-operate operators, eg: `+=`, `-=`, `||=`, etc., the object must have both a reader and writer method. In other words, it needs to have been created as an `tlv_accessor`.
121
134
 
@@ -130,9 +143,17 @@ Alternative block forms:
130
143
  tlv_set(name) { |oldval| newval }
131
144
  tlv_set_once(name) { |oldval| newval }
132
145
 
133
-
134
146
  In all cases, the `name` can be a string or symbol, with or without a leading `@`.
135
147
 
148
+ Ultimately, these methods are all doing these basic accesses of the corresponding instance variables:
149
+
150
+ @name1 ||= ThreadLocalVar.new
151
+ @name1.value = per_thread_value
152
+ ...
153
+ @name1.value # returns the per_thread_value
154
+
155
+ If you prefer the style above, then you don't really need these accessor methods.
156
+
136
157
  ### Example Usage
137
158
 
138
159
  ```ruby
@@ -1,3 +1,3 @@
1
1
  module ThreadLocalVarAccessors
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thread_local_var_accessors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alan Stebbens
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-28 00:00:00.000000000 Z
11
+ date: 2023-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler