cache_rocket 0.5.0 → 0.5.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: 378ac5399bdb7f58e8c5b3dfeaea5a76c4369997
4
- data.tar.gz: 6d0835c56392e598f0b2fff73c6296bb25efd2be
3
+ metadata.gz: 127bbbf2d03cd8f29d2fbf71eabe3f80f218088c
4
+ data.tar.gz: 231d24676b56a959e4fb988df98c9891098b7f16
5
5
  SHA512:
6
- metadata.gz: 85ff2503338f81cc30a5f9ccb68917e1ff9cd3395294ae7a51503c6f4e46920d25b76d84d5d0ee87277b9a134eb2d603e235cbdcd416f247c454ecb8e01dcdaf
7
- data.tar.gz: 47af1c4e271361ae739086a237c574d5bca195eee62ea06557d417db16c2c10a62b405e94b47d7e01c7b7e9bec1d7218dec268a409d5125d90075ab2263cdfd6
6
+ metadata.gz: df4ca70e460b54af44adb5539378b895e6dc86b384e8b3dd3b2024be7b2dd648105ca833bfee2f7ea10d029105623d81f1a8f5ba50fd9610c126946a92374db9
7
+ data.tar.gz: dc06d403bdb980ff4c3ca0c80ab5ef3e098fdfdaa18f8d22f1f2f409887ad4968d282b106b203044d312f15544751ec45b1ab2fa17416fe227f158c9357792f5
data/README.md CHANGED
@@ -22,7 +22,7 @@ Add the gem to your Gemfile:
22
22
  gem 'cache_rocket'
23
23
  ```
24
24
 
25
- Include the CacheRocket module so your views can use the `render_cached` method.
25
+ Include the CacheRocket module so your views can use the `cache_replace` and `render_cached` methods.
26
26
  Most likely you would put this in your `ApplicationHelper`:
27
27
 
28
28
  ```ruby
@@ -32,11 +32,11 @@ include CacheRocket
32
32
  ## Use
33
33
 
34
34
  CacheRocket allows you to cache a fragment of html and replace inner html.
35
- You inject dynamic content into a static, cached outer partial.
35
+ You inject dynamic content into a cached fragment that contains a placeholder.
36
36
 
37
37
  ### `cache_replace`
38
38
 
39
- The simplest usage is inline with the `cache_replace` helper. It works
39
+ The simplest usage is inline with the `cache_replace` method. It works
40
40
  like Rails' `cache` method, plus it replaces content that you do not want
41
41
  to cache because it is impractical or inefficient.
42
42
 
@@ -45,19 +45,24 @@ For example:
45
45
  #### Before
46
46
 
47
47
  ```haml
48
- .htmls
48
+ .lots.of.htmls
49
49
  = Time.now
50
+ .more.htmls
51
+ = user.name
50
52
  ```
51
53
 
52
54
  #### After
53
55
 
54
56
  ```haml
55
- - cache_replace("the-time", replace: { time: Time.now }) do
56
- .htmls
57
+ - cache_replace("some-key", replace: { time: Time.now, name: user.name }) do
58
+ .lots.of.htmls
57
59
  = cache_replace_key :time
60
+ .more.htmls
61
+ = cache_replace_key :name
58
62
  ```
59
63
 
60
- Now the fragment is cached once with a placeholder, and the time is always replaced when rendered.
64
+ Now the fragment is cached once with placeholders, and the time and user name are
65
+ replaced when rendered.
61
66
 
62
67
  Obviously, the above example is contrived and would not result in any
63
68
  performance benefit. When the block of html you are rendering is large,
@@ -168,14 +173,14 @@ render_cached 'outer', replace: ['inner', 'footer']
168
173
  #### Hash of keys to replace with values
169
174
 
170
175
  ```ruby
171
- render_cached 'outer', replace: { key_name: a_helper_method(object) }
176
+ render_cached 'outer', replace: { key_name: a_method(object) }
172
177
  ```
173
178
 
174
179
  #### Block containing a hash of keys to replace with values
175
180
 
176
181
  ```ruby
177
182
  render_cached 'outer' do
178
- { key_name: a_helper_method(object) }
183
+ { key_name: a_method(object) }
179
184
  end
180
185
  ```
181
186
 
@@ -183,14 +188,14 @@ end
183
188
 
184
189
  ```ruby
185
190
  render_cached 'outer', collection: objects,
186
- replace: { key_name: -> (object) { a_helper_method(object) } }
191
+ replace: { key_name: -> (object) { a_method(object) } }
187
192
  ```
188
193
 
189
194
  #### Render a collection with block syntax
190
195
 
191
196
  ```ruby
192
197
  render_cached 'outer', collection: objects do
193
- { key_name: -> (object) { a_helper_method(object) } }
198
+ { key_name: -> (object) { a_method(object) } }
194
199
  end
195
200
  ```
196
201
 
@@ -199,7 +204,7 @@ end
199
204
  ```ruby
200
205
  render_cached 'outer', collection: objects do
201
206
  {
202
- key_1: -> (object) { a_helper_method(object) },
207
+ key_1: -> (object) { a_method(object) },
203
208
  key_2: -> (item) { item.name },
204
209
  }
205
210
  end
@@ -5,7 +5,7 @@ module CacheRocket
5
5
  include Key
6
6
 
7
7
  def initialize(value)
8
- @value = value
8
+ @value = value.to_s.dup
9
9
  end
10
10
 
11
11
  def to_s
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CacheRocket
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cache_rocket
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tee Parham