rails_before_render 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.version +1 -1
- data/lib/rails_before_render.rb +12 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21d54661040540a9e8d50e1cb9b7088c2b777023
|
4
|
+
data.tar.gz: efbbc3df00e9a48b07f1c2de7d4eb99b40e3705a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d52eefee7cd47cc8fbf035df01ba2143778c1e816623bc8b271546a97648770df69dde641af7a35099e4b106c14c8dad11643a11c11ce45752aac5a0a6d24cdb
|
7
|
+
data.tar.gz: d7c27f0028a221eff683bf69d85eaf2d582b3e357144ffdedfbbf598e1067ab4dfd1d4fd0a7bd0b5ca45c0845b4b5a1600dddf8223ce6849d0c9639fea592240
|
data/.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.6
|
data/lib/rails_before_render.rb
CHANGED
@@ -1,24 +1,30 @@
|
|
1
|
+
require 'digest'
|
2
|
+
|
1
3
|
module RailsBeforeRender
|
2
4
|
@@_before_render ||= {}
|
3
5
|
|
4
6
|
def self.included base
|
5
7
|
def base.before_render_filter &block
|
6
8
|
klass = self.to_s
|
7
|
-
|
8
|
-
|
9
|
+
key = Digest::MD5.hexdigest(caller[0])
|
10
|
+
|
11
|
+
@@_before_render[klass] ||= {}
|
12
|
+
@@_before_render[klass][key] = block
|
9
13
|
end
|
10
14
|
end
|
11
15
|
|
12
16
|
###
|
13
17
|
|
14
18
|
def render *args
|
15
|
-
|
16
|
-
|
17
|
-
|
19
|
+
if @_was_in_render
|
20
|
+
return performed? ? nil : super(*args)
|
21
|
+
else
|
22
|
+
@_was_in_render = true
|
23
|
+
end
|
18
24
|
|
19
25
|
self.class.ancestors.each do |klass|
|
20
26
|
filters = @@_before_render[klass.to_s] || next
|
21
|
-
filters.each do |filter|
|
27
|
+
filters.values.each do |filter|
|
22
28
|
# do not run if render or redirect is called
|
23
29
|
instance_exec &filter unless performed?
|
24
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_before_render
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dino Reic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fast_blank
|
@@ -53,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
53
|
version: '0'
|
54
54
|
requirements: []
|
55
55
|
rubyforge_project:
|
56
|
-
rubygems_version: 2.6.
|
56
|
+
rubygems_version: 2.6.14
|
57
57
|
signing_key:
|
58
58
|
specification_version: 4
|
59
59
|
summary: Missing Ruby on Rails before_render controller filter
|