configatron 3.1.0 → 3.1.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
  SHA1:
3
- metadata.gz: 84ff6f84518b18e89af32df3249a42d4adde63c6
4
- data.tar.gz: ed208d199f8334bda0b371098eeaf9f035f390a1
3
+ metadata.gz: 43ae27d34852f0d6b2bc628059ad7189f2695d04
4
+ data.tar.gz: 5c8e68f8aafbf7d9f30ddc3a95110cee6405f0fe
5
5
  SHA512:
6
- metadata.gz: 68368a752c61057a128b2a84f610e1d384a2ac198ab104689ec7129fb1723a4183dc864550914a08394fee2bf0301b2a3a33c3cd18ba11cc0ae30fd9ff95df5e
7
- data.tar.gz: 178b8532496c4c85ef94a478073283d333ca37be95ecaa9c811bd996c54a9e0181a0cdbb73cd6970e3d4d6b9500d35f2bcdd4529fc46b82b78da45e9bc6fe9d5
6
+ metadata.gz: 7f5ba8a9bcc0785bea2cbd94f8c3983485953456be4e308bdc49bb32c93ba0a31aa6c69afe97ca67a48525262b99294ff7425948b82ad0e01349235614d0ee16
7
+ data.tar.gz: cb430f0b8c6fbe6051745b23eb26e06f45ed78814fef5f1f464e1083368fe620c7ebc3ea4c02e8732292735ab8593543fdc8cc12cf7ae6afe1b5353bddbb826e
data/Gemfile.lock CHANGED
@@ -9,7 +9,7 @@ GIT
9
9
  PATH
10
10
  remote: .
11
11
  specs:
12
- configatron (3.1.0)
12
+ configatron (3.1.1)
13
13
 
14
14
  GEM
15
15
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -139,6 +139,56 @@ configatron.letters.b # => 'B'
139
139
  configatron.letters.c # => {}
140
140
  ```
141
141
 
142
+ ### Delayed and Dynamic Configurations
143
+
144
+ There are times when you want to refer to one configuration setting in another configuration setting. Let's look at a fairly contrived example:
145
+
146
+ ```ruby
147
+ configatron.memcached.servers = ['127.0.0.1:11211']
148
+ configatron.page_caching.servers = configatron.memcached.servers
149
+ configatron.object_caching.servers = configatron.memcached.servers
150
+
151
+ if Rails.env == 'production'
152
+ configatron.memcached.servers = ['192.168.0.1:11211']
153
+ configatron.page_caching.servers = configatron.memcached.servers
154
+ configatron.object_caching.servers = configatron.memcached.servers
155
+ elsif Rails.env == 'staging'
156
+ configatron.memcached.servers = ['192.168.0.2:11211']
157
+ configatron.page_caching.servers = configatron.memcached.servers
158
+ configatron.object_caching.servers = configatron.memcached.servers
159
+ end
160
+ ```
161
+
162
+ Now, we could've written that slightly differently, but it helps to illustrate the point. With Configatron you can create `Delayed` and `Dynamic` settings.
163
+
164
+ #### Delayed
165
+
166
+ With `Delayed` settings execution of the setting doesn't happen until the first time it is executed.
167
+
168
+ ```ruby
169
+ configatron.memcached.servers = ['127.0.0.1:11211']
170
+ configatron.page_caching.servers = Configatron::Delayed.new {configatron.memcached.servers}
171
+ configatron.object_caching.servers = Configatron::Delayed.new {configatron.memcached.servers}
172
+
173
+ if Rails.env == 'production'
174
+ configatron.memcached.servers = ['192.168.0.1:11211']
175
+ elsif Rails.env == 'staging'
176
+ configatron.memcached.servers = ['192.168.0.2:11211']
177
+ end
178
+ ```
179
+
180
+ Execution occurs once and after that the result of that execution is returned. So in our case the first time someone calls the setting `configatron.page_caching.servers` it will find the `configatron.memcached.servers` setting and return that. After that point if the `configatron.memcached.servers` setting is changed, the original settings are returned by `configatron.page_caching.servers`.
181
+
182
+ #### Dynamic
183
+
184
+ `Dynamic` settings are very similar to `Delayed` settings, but with one big difference. Every time you call a `Dynamic` setting is executed. Take this example:
185
+
186
+ ```ruby
187
+ configatron.current.time = Configatron::Dynamic.new {Time.now}
188
+ ```
189
+
190
+ Each time you call `configatron.current.time` it will return a new value to you. While this seems a bit useless, it is pretty useful if you have ever changing configurations.
191
+
142
192
  ### nil
143
193
 
144
194
  Even if parameters haven't been set, you can still call them, but you'll get a `Configatron::Store` object back. The `Configatron::Store` class, however, will respond true to `.nil?` or `.blank?` if there are no parameters configured on it.
@@ -241,8 +291,8 @@ configatron.to_h # => {:letters=>{:a=>"A", :b=>"BB", :c=>"C"}}
241
291
  * Mark Bates
242
292
  * Kurtis Rainbolt-Greene
243
293
  * Rob Sanheim
244
- * Greg Brockman
245
294
  * Jérémy Lecour
295
+ * Greg Brockman
246
296
  * Cody Maggard
247
297
  * Jean-Denis Vauguet
248
298
  * Torsten Schönebaum
@@ -258,4 +308,4 @@ configatron.to_h # => {:letters=>{:a=>"A", :b=>"BB", :c=>"C"}}
258
308
  * joe miller
259
309
  * Brandon Dimcheff
260
310
  * Rick Fletcher
261
- * Josh Nichol
311
+ * Josh Nichols
@@ -1,3 +1,3 @@
1
1
  class Configatron
2
- VERSION = "3.1.0"
2
+ VERSION = "3.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configatron
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Bates