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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/.version +1 -1
  3. data/lib/rails_before_render.rb +12 -6
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8be3c2877d34be1abbd791da92a714c0a78d008e
4
- data.tar.gz: 0000c1ee5011566838e06b9b1fb714e4fa8b6bb1
3
+ metadata.gz: 21d54661040540a9e8d50e1cb9b7088c2b777023
4
+ data.tar.gz: efbbc3df00e9a48b07f1c2de7d4eb99b40e3705a
5
5
  SHA512:
6
- metadata.gz: 4c7ce7557535c8ab2dd392eeccc00a98391fad5bc4e7556746c140997a19499cc934a72e802e0c64fb044ba5fb1882fcdabff9f6e462010e88f81365301baa57
7
- data.tar.gz: 8f551dd83a66cce9f50bc248a12d68ce4fd7bb23e5b1f7cfd45c2107d0ca63ded3ec5bb3042d945873797deffa8630e6b8b325a4dfd03825ecf0cd8c6b97e7e7
6
+ metadata.gz: d52eefee7cd47cc8fbf035df01ba2143778c1e816623bc8b271546a97648770df69dde641af7a35099e4b106c14c8dad11643a11c11ce45752aac5a0a6d24cdb
7
+ data.tar.gz: d7c27f0028a221eff683bf69d85eaf2d582b3e357144ffdedfbbf598e1067ab4dfd1d4fd0a7bd0b5ca45c0845b4b5a1600dddf8223ce6849d0c9639fea592240
data/.version CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
@@ -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
- @@_before_render[klass] ||= []
8
- @@_before_render[klass].push block
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
- return performed? ? nil : super(*args) if @_was_in_render
16
-
17
- @_was_in_render = true
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.5
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-09-14 00:00:00.000000000 Z
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.10
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