stimulus_reflex 3.4.0 → 3.4.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of stimulus_reflex might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e8a031b4ca8ec37431ba1833e979dd07a1bfcc9e91c76eb8ced068811b882a5
4
- data.tar.gz: 9c0624e343247459836718dac05cc25b4a75d4952bcdbb15a175211785e8e174
3
+ metadata.gz: 6f74577e73a2f026446a9992c687779adc90905fc20d7023c0020079608e365c
4
+ data.tar.gz: ea5c955d176363fdfd7634e51025c3b6948577b814f318e5674f7e7136d6a4a1
5
5
  SHA512:
6
- metadata.gz: 3abd618c996936a1e118ee552a95a97c6481014a008c32775d11c2c2c9ea1e1e691071c9a1e8016722fec7f66cb63049b57f0331b283e45704bdc7bb253dc888
7
- data.tar.gz: 92f4c07b36962fb3d6858dcc8e051d8c584cb0851198574cfe77e8be580d77d4fbd5f4f6a6693b59a76c52be7cd614a0bf5b67cf536dfa8c80ed70391d87849c
6
+ metadata.gz: f9410027ca56f055ef6cbf630cd1ecb6c1110d2021be6e1d1a854721525a2ab49bcc413b91d4d29ed4f952afba85d0168a2622dd3b1c06a7f87465dd01e7aaf1
7
+ data.tar.gz: c1a0e8e3a4ed13bed29beee77c866877a9cbf781e85140d105168ba2e8574bb9f43cf8db7f6eba6249e07e673aa1efab541d84f5778a36bc34dd6c53e804c5b1
@@ -2,7 +2,38 @@
2
2
 
3
3
  ## [Unreleased](https://github.com/hopsoft/stimulus_reflex/tree/HEAD)
4
4
 
5
- [Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.4.0.pre9...HEAD)
5
+ [Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.4.0...HEAD)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - controller element holds Reflex metadata [\#417](https://github.com/hopsoft/stimulus_reflex/pull/417) ([leastbad](https://github.com/leastbad))
10
+
11
+ **Fixed bugs:**
12
+
13
+ - life-cycle callbacks return correct element reference [\#431](https://github.com/hopsoft/stimulus_reflex/pull/431) ([leastbad](https://github.com/leastbad))
14
+ - encode form data for chars like '&' and '=' [\#418](https://github.com/hopsoft/stimulus_reflex/pull/418) ([RolandStuder](https://github.com/RolandStuder))
15
+ - Bug fix: Updating changelog generator to push to master, not main [\#416](https://github.com/hopsoft/stimulus_reflex/pull/416) ([MikeRogers0](https://github.com/MikeRogers0))
16
+ - Prefix dom\_id with hash/pound [\#410](https://github.com/hopsoft/stimulus_reflex/pull/410) ([hopsoft](https://github.com/hopsoft))
17
+
18
+ **Closed issues:**
19
+
20
+ - Form serialisation does not escape input values [\#430](https://github.com/hopsoft/stimulus_reflex/issues/430)
21
+ - dispatchEvent before morph in reflex actions [\#428](https://github.com/hopsoft/stimulus_reflex/issues/428)
22
+ - Multiple text inputs with the same name lose value in Reflex [\#425](https://github.com/hopsoft/stimulus_reflex/issues/425)
23
+ - Lifecycle events not being issued correctly [\#413](https://github.com/hopsoft/stimulus_reflex/issues/413)
24
+ - If the element no longer exists, try to find it. [\#412](https://github.com/hopsoft/stimulus_reflex/issues/412)
25
+
26
+ **Merged pull requests:**
27
+
28
+ - Fixes bug where multiple inputs with the same name lost element value [\#426](https://github.com/hopsoft/stimulus_reflex/pull/426) ([jonsgreen](https://github.com/jonsgreen))
29
+ - Update to work with mutatable CR config [\#421](https://github.com/hopsoft/stimulus_reflex/pull/421) ([hopsoft](https://github.com/hopsoft))
30
+ - Bump nokogiri from 1.10.10 to 1.11.1 [\#420](https://github.com/hopsoft/stimulus_reflex/pull/420) ([dependabot[bot]](https://github.com/apps/dependabot))
31
+ - Add matrix strategy to ruby tests [\#415](https://github.com/hopsoft/stimulus_reflex/pull/415) ([julianrubisch](https://github.com/julianrubisch))
32
+ - fix 'operartion' typo [\#411](https://github.com/hopsoft/stimulus_reflex/pull/411) ([marcoroth](https://github.com/marcoroth))
33
+
34
+ ## [v3.4.0](https://github.com/hopsoft/stimulus_reflex/tree/v3.4.0) (2020-12-18)
35
+
36
+ [Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.4.0.pre9...v3.4.0)
6
37
 
7
38
  **Closed issues:**
8
39
 
@@ -70,7 +101,6 @@
70
101
  - Update templates for new stage etc [\#390](https://github.com/hopsoft/stimulus_reflex/pull/390) ([leastbad](https://github.com/leastbad))
71
102
  - reflexError and received refactor [\#389](https://github.com/hopsoft/stimulus_reflex/pull/389) ([leastbad](https://github.com/leastbad))
72
103
  - add jQuery support to SR library events [\#388](https://github.com/hopsoft/stimulus_reflex/pull/388) ([leastbad](https://github.com/leastbad))
73
- - dont exit in sanity checker on `stimulus\_reflex:install` [\#387](https://github.com/hopsoft/stimulus_reflex/pull/387) ([marcoroth](https://github.com/marcoroth))
74
104
  - Allow `success` and `after` lifecycle methods on replaced elements [\#386](https://github.com/hopsoft/stimulus_reflex/pull/386) ([marcoroth](https://github.com/marcoroth))
75
105
  - split SR operations from data.operations [\#385](https://github.com/hopsoft/stimulus_reflex/pull/385) ([leastbad](https://github.com/leastbad))
76
106
  - don't show findElement warnings unless debugging [\#384](https://github.com/hopsoft/stimulus_reflex/pull/384) ([leastbad](https://github.com/leastbad))
@@ -87,6 +117,7 @@
87
117
 
88
118
  **Merged pull requests:**
89
119
 
120
+ - dont exit in sanity checker on `stimulus\_reflex:install` [\#387](https://github.com/hopsoft/stimulus_reflex/pull/387) ([marcoroth](https://github.com/marcoroth))
90
121
  - Move package.json to root of project [\#380](https://github.com/hopsoft/stimulus_reflex/pull/380) ([hopsoft](https://github.com/hopsoft))
91
122
  - make element.reflexController a dictionary [\#379](https://github.com/hopsoft/stimulus_reflex/pull/379) ([existentialmutt](https://github.com/existentialmutt))
92
123
  - fixed bug preventing callbacks for multiple morphs [\#378](https://github.com/hopsoft/stimulus_reflex/pull/378) ([leastbad](https://github.com/leastbad))
@@ -441,7 +472,6 @@
441
472
  - Loosen Rails requirement to 5.2 with instructions [\#205](https://github.com/hopsoft/stimulus_reflex/pull/205) ([jasoncharnes](https://github.com/jasoncharnes))
442
473
  - Fix undefined is not an object for Object.keys in log.js [\#201](https://github.com/hopsoft/stimulus_reflex/pull/201) ([marcoroth](https://github.com/marcoroth))
443
474
  - Small typo/grammar fix in quickstart doc. [\#198](https://github.com/hopsoft/stimulus_reflex/pull/198) ([acoffman](https://github.com/acoffman))
444
- - Add halted lifecycle event [\#193](https://github.com/hopsoft/stimulus_reflex/pull/193) ([websebdev](https://github.com/websebdev))
445
475
  - 147 extract multiple checkbox values [\#175](https://github.com/hopsoft/stimulus_reflex/pull/175) ([julianrubisch](https://github.com/julianrubisch))
446
476
 
447
477
  ## [v3.2.1](https://github.com/hopsoft/stimulus_reflex/tree/v3.2.1) (2020-05-09)
@@ -493,6 +523,7 @@
493
523
 
494
524
  **Merged pull requests:**
495
525
 
526
+ - Add halted lifecycle event [\#193](https://github.com/hopsoft/stimulus_reflex/pull/193) ([websebdev](https://github.com/websebdev))
496
527
  - Some housekeeping [\#189](https://github.com/hopsoft/stimulus_reflex/pull/189) ([hopsoft](https://github.com/hopsoft))
497
528
  - Allow to call stimulate without a reflex target [\#188](https://github.com/hopsoft/stimulus_reflex/pull/188) ([marcoroth](https://github.com/marcoroth))
498
529
  - Fix bug in super documentation [\#174](https://github.com/hopsoft/stimulus_reflex/pull/174) ([silva96](https://github.com/silva96))
@@ -61,6 +61,12 @@ is deemed necessary and appropriate to the circumstances. The project team is
61
61
  obligated to maintain confidentiality with regard to the reporter of an incident.
62
62
  Further details of specific enforcement policies may be posted separately.
63
63
 
64
+ ### General Policy
65
+
66
+ - 1st offense - user will be warned that they violated the CoC
67
+ - 2nd offense - user will be publicly flagged as a CoC violator
68
+ - 3rd offense - user will be banned from the community
69
+
64
70
  Project maintainers who do not follow or enforce the Code of Conduct in good
65
71
  faith may face temporary or permanent repercussions as determined by other
66
72
  members of the project's leadership.
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stimulus_reflex (3.4.0)
5
- cable_ready (>= 4.4)
4
+ stimulus_reflex (3.4.1)
5
+ cable_ready (>= 4.5)
6
6
  nokogiri
7
7
  rack
8
8
  rails (>= 5.2)
@@ -11,78 +11,79 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- actioncable (6.1.0)
15
- actionpack (= 6.1.0)
16
- activesupport (= 6.1.0)
14
+ actioncable (6.1.1)
15
+ actionpack (= 6.1.1)
16
+ activesupport (= 6.1.1)
17
17
  nio4r (~> 2.0)
18
18
  websocket-driver (>= 0.6.1)
19
- actionmailbox (6.1.0)
20
- actionpack (= 6.1.0)
21
- activejob (= 6.1.0)
22
- activerecord (= 6.1.0)
23
- activestorage (= 6.1.0)
24
- activesupport (= 6.1.0)
19
+ actionmailbox (6.1.1)
20
+ actionpack (= 6.1.1)
21
+ activejob (= 6.1.1)
22
+ activerecord (= 6.1.1)
23
+ activestorage (= 6.1.1)
24
+ activesupport (= 6.1.1)
25
25
  mail (>= 2.7.1)
26
- actionmailer (6.1.0)
27
- actionpack (= 6.1.0)
28
- actionview (= 6.1.0)
29
- activejob (= 6.1.0)
30
- activesupport (= 6.1.0)
26
+ actionmailer (6.1.1)
27
+ actionpack (= 6.1.1)
28
+ actionview (= 6.1.1)
29
+ activejob (= 6.1.1)
30
+ activesupport (= 6.1.1)
31
31
  mail (~> 2.5, >= 2.5.4)
32
32
  rails-dom-testing (~> 2.0)
33
- actionpack (6.1.0)
34
- actionview (= 6.1.0)
35
- activesupport (= 6.1.0)
33
+ actionpack (6.1.1)
34
+ actionview (= 6.1.1)
35
+ activesupport (= 6.1.1)
36
36
  rack (~> 2.0, >= 2.0.9)
37
37
  rack-test (>= 0.6.3)
38
38
  rails-dom-testing (~> 2.0)
39
39
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
40
- actiontext (6.1.0)
41
- actionpack (= 6.1.0)
42
- activerecord (= 6.1.0)
43
- activestorage (= 6.1.0)
44
- activesupport (= 6.1.0)
40
+ actiontext (6.1.1)
41
+ actionpack (= 6.1.1)
42
+ activerecord (= 6.1.1)
43
+ activestorage (= 6.1.1)
44
+ activesupport (= 6.1.1)
45
45
  nokogiri (>= 1.8.5)
46
- actionview (6.1.0)
47
- activesupport (= 6.1.0)
46
+ actionview (6.1.1)
47
+ activesupport (= 6.1.1)
48
48
  builder (~> 3.1)
49
49
  erubi (~> 1.4)
50
50
  rails-dom-testing (~> 2.0)
51
51
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
52
- activejob (6.1.0)
53
- activesupport (= 6.1.0)
52
+ activejob (6.1.1)
53
+ activesupport (= 6.1.1)
54
54
  globalid (>= 0.3.6)
55
- activemodel (6.1.0)
56
- activesupport (= 6.1.0)
57
- activerecord (6.1.0)
58
- activemodel (= 6.1.0)
59
- activesupport (= 6.1.0)
60
- activestorage (6.1.0)
61
- actionpack (= 6.1.0)
62
- activejob (= 6.1.0)
63
- activerecord (= 6.1.0)
64
- activesupport (= 6.1.0)
55
+ activemodel (6.1.1)
56
+ activesupport (= 6.1.1)
57
+ activerecord (6.1.1)
58
+ activemodel (= 6.1.1)
59
+ activesupport (= 6.1.1)
60
+ activestorage (6.1.1)
61
+ actionpack (= 6.1.1)
62
+ activejob (= 6.1.1)
63
+ activerecord (= 6.1.1)
64
+ activesupport (= 6.1.1)
65
65
  marcel (~> 0.3.1)
66
66
  mimemagic (~> 0.3.2)
67
- activesupport (6.1.0)
67
+ activesupport (6.1.1)
68
68
  concurrent-ruby (~> 1.0, >= 1.0.2)
69
69
  i18n (>= 1.6, < 2)
70
70
  minitest (>= 5.1)
71
71
  tzinfo (~> 2.0)
72
72
  zeitwerk (~> 2.3)
73
- ast (2.4.1)
73
+ ast (2.4.2)
74
74
  builder (3.2.4)
75
- cable_ready (4.4.6)
75
+ cable_ready (4.5.0)
76
76
  rails (>= 5.2)
77
+ thread-local (>= 1.1.0)
77
78
  coderay (1.1.3)
78
- concurrent-ruby (1.1.7)
79
+ concurrent-ruby (1.1.8)
79
80
  crass (1.0.6)
80
81
  erubi (1.10.0)
81
82
  globalid (0.4.2)
82
83
  activesupport (>= 4.2.0)
83
- i18n (1.8.5)
84
+ i18n (1.8.7)
84
85
  concurrent-ruby (~> 1.0)
85
- loofah (2.8.0)
86
+ loofah (2.9.0)
86
87
  crass (~> 1.0.2)
87
88
  nokogiri (>= 1.5.9)
88
89
  mail (2.7.1)
@@ -92,68 +93,70 @@ GEM
92
93
  method_source (0.9.2)
93
94
  mimemagic (0.3.5)
94
95
  mini_mime (1.0.2)
95
- mini_portile2 (2.4.0)
96
- minitest (5.14.2)
96
+ mini_portile2 (2.5.0)
97
+ minitest (5.14.3)
97
98
  nio4r (2.5.4)
98
- nokogiri (1.10.10)
99
- mini_portile2 (~> 2.4.0)
99
+ nokogiri (1.11.1)
100
+ mini_portile2 (~> 2.5.0)
101
+ racc (~> 1.4)
100
102
  parallel (1.20.1)
101
- parser (2.7.2.0)
103
+ parser (3.0.0.0)
102
104
  ast (~> 2.4.1)
103
105
  pry (0.12.2)
104
106
  coderay (~> 1.1.0)
105
107
  method_source (~> 0.9.0)
106
108
  pry-nav (0.3.0)
107
109
  pry (>= 0.9.10, < 0.13.0)
110
+ racc (1.5.2)
108
111
  rack (2.2.3)
109
112
  rack-test (1.1.0)
110
113
  rack (>= 1.0, < 3)
111
- rails (6.1.0)
112
- actioncable (= 6.1.0)
113
- actionmailbox (= 6.1.0)
114
- actionmailer (= 6.1.0)
115
- actionpack (= 6.1.0)
116
- actiontext (= 6.1.0)
117
- actionview (= 6.1.0)
118
- activejob (= 6.1.0)
119
- activemodel (= 6.1.0)
120
- activerecord (= 6.1.0)
121
- activestorage (= 6.1.0)
122
- activesupport (= 6.1.0)
114
+ rails (6.1.1)
115
+ actioncable (= 6.1.1)
116
+ actionmailbox (= 6.1.1)
117
+ actionmailer (= 6.1.1)
118
+ actionpack (= 6.1.1)
119
+ actiontext (= 6.1.1)
120
+ actionview (= 6.1.1)
121
+ activejob (= 6.1.1)
122
+ activemodel (= 6.1.1)
123
+ activerecord (= 6.1.1)
124
+ activestorage (= 6.1.1)
125
+ activesupport (= 6.1.1)
123
126
  bundler (>= 1.15.0)
124
- railties (= 6.1.0)
127
+ railties (= 6.1.1)
125
128
  sprockets-rails (>= 2.0.0)
126
129
  rails-dom-testing (2.0.3)
127
130
  activesupport (>= 4.2.0)
128
131
  nokogiri (>= 1.6)
129
132
  rails-html-sanitizer (1.3.0)
130
133
  loofah (~> 2.3)
131
- railties (6.1.0)
132
- actionpack (= 6.1.0)
133
- activesupport (= 6.1.0)
134
+ railties (6.1.1)
135
+ actionpack (= 6.1.1)
136
+ activesupport (= 6.1.1)
134
137
  method_source
135
138
  rake (>= 0.8.7)
136
139
  thor (~> 1.0)
137
140
  rainbow (3.0.0)
138
- rake (13.0.1)
141
+ rake (13.0.3)
139
142
  redis (4.2.5)
140
- regexp_parser (2.0.0)
143
+ regexp_parser (2.0.3)
141
144
  rexml (3.2.4)
142
- rubocop (1.4.2)
145
+ rubocop (1.7.0)
143
146
  parallel (~> 1.10)
144
147
  parser (>= 2.7.1.5)
145
148
  rainbow (>= 2.2.2, < 4.0)
146
- regexp_parser (>= 1.8)
149
+ regexp_parser (>= 1.8, < 3.0)
147
150
  rexml
148
- rubocop-ast (>= 1.1.1)
151
+ rubocop-ast (>= 1.2.0, < 2.0)
149
152
  ruby-progressbar (~> 1.7)
150
153
  unicode-display_width (>= 1.4.0, < 2.0)
151
- rubocop-ast (1.3.0)
154
+ rubocop-ast (1.4.1)
152
155
  parser (>= 2.7.1.5)
153
- rubocop-performance (1.9.1)
156
+ rubocop-performance (1.9.2)
154
157
  rubocop (>= 0.90.0, < 2.0)
155
158
  rubocop-ast (>= 0.4.0)
156
- ruby-progressbar (1.10.1)
159
+ ruby-progressbar (1.11.0)
157
160
  sprockets (4.0.2)
158
161
  concurrent-ruby (~> 1.0)
159
162
  rack (> 1, < 3)
@@ -161,12 +164,13 @@ GEM
161
164
  actionpack (>= 4.0)
162
165
  activesupport (>= 4.0)
163
166
  sprockets (>= 3.0.0)
164
- standard (0.10.2)
165
- rubocop (= 1.4.2)
166
- rubocop-performance (= 1.9.1)
167
+ standard (0.11.0)
168
+ rubocop (= 1.7.0)
169
+ rubocop-performance (= 1.9.2)
167
170
  standardrb (1.0.0)
168
171
  standard
169
- thor (1.0.1)
172
+ thor (1.1.0)
173
+ thread-local (1.1.0)
170
174
  tzinfo (2.0.4)
171
175
  concurrent-ruby (~> 1.0)
172
176
  unicode-display_width (1.7.0)
data/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
  <img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-brightgreen.svg" target="_blank" />
12
12
  </a>
13
13
  <a href="http://blog.codinghorror.com/the-best-code-is-no-code-at-all/" target="_blank">
14
- <img alt="Lines of Code" src="https://img.shields.io/badge/lines_of_code-1632-brightgreen.svg?style=flat" />
14
+ <img alt="Lines of Code" src="https://img.shields.io/badge/lines_of_code-1726-brightgreen.svg?style=flat" />
15
15
  </a>
16
16
  <a href="https://docs.stimulusreflex.com/" target="_blank">
17
17
  <img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" />
@@ -65,6 +65,7 @@ This project strives to live up to the vision outlined in [The Rails Doctrine](h
65
65
 
66
66
  - [StimulusReflex Documentation](https://docs.stimulusreflex.com)
67
67
  - [CableReady Documentation](https://cableready.stimulusreflex.com)
68
+ - [StimulusReflex Cheatsheet](https://devhints.io/stimulus-reflex)
68
69
 
69
70
  ## ✨ Demos
70
71
 
@@ -74,7 +75,7 @@ This project strives to live up to the vision outlined in [The Rails Doctrine](h
74
75
 
75
76
  ## 👩‍👩‍👧 Discord Community
76
77
 
77
- Please join over 800 of us on [Discord](https://discord.gg/XveN625) for support getting started, as well as active discussions around Rails, StimulusJS and CableReady.
78
+ Please join over 1000 of us on [Discord](https://discord.gg/XveN625) for support getting started, as well as active discussions around Rails, StimulusJS and CableReady.
78
79
 
79
80
  ![](https://img.shields.io/discord/629472241427415060)
80
81
 
@@ -40,8 +40,8 @@ class StimulusReflex::Channel < StimulusReflex.configuration.parent_channel.cons
40
40
  params: params,
41
41
  client_attributes: {
42
42
  reflex_id: data["reflexId"],
43
- xpath: data["xpath"],
44
- c_xpath: data["cXpath"],
43
+ xpath_controller: data["xpathController"],
44
+ xpath_element: data["xpathElement"],
45
45
  reflex_controller: data["reflexController"],
46
46
  permanent_attribute_name: permanent_attribute_name
47
47
  })
@@ -11,6 +11,7 @@ require "cable_ready"
11
11
  require "stimulus_reflex/version"
12
12
  require "stimulus_reflex/cable_ready_channels"
13
13
  require "stimulus_reflex/configuration"
14
+ require "stimulus_reflex/callbacks"
14
15
  require "stimulus_reflex/reflex"
15
16
  require "stimulus_reflex/element"
16
17
  require "stimulus_reflex/sanity_checker"
@@ -2,8 +2,6 @@
2
2
 
3
3
  module StimulusReflex
4
4
  class CableReadyChannels
5
- stimulus_reflex_channel_methods = CableReady::Channels.instance.operations.keys + [:broadcast, :broadcast_to]
6
- delegate(*stimulus_reflex_channel_methods, to: "stimulus_reflex_channel")
7
5
  delegate :[], to: "cable_ready_channels"
8
6
 
9
7
  def initialize(stream_name)
@@ -17,5 +15,14 @@ module StimulusReflex
17
15
  def stimulus_reflex_channel
18
16
  CableReady::Channels.instance[@stream_name]
19
17
  end
18
+
19
+ def method_missing(name, *args)
20
+ return stimulus_reflex_channel.public_send(name, *args) if stimulus_reflex_channel.respond_to?(name)
21
+ super
22
+ end
23
+
24
+ def respond_to_missing?(name, include_all)
25
+ stimulus_reflex_channel.respond_to?(name) || super
26
+ end
20
27
  end
21
28
  end
@@ -0,0 +1,48 @@
1
+ require "active_support/concern"
2
+
3
+ module StimulusReflex
4
+ module Callbacks
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ include ActiveSupport::Callbacks
9
+ define_callbacks :process, skip_after_callbacks_if_terminated: true
10
+ end
11
+
12
+ class_methods do
13
+ def before_reflex(*args, &block)
14
+ add_callback(:before, *args, &block)
15
+ end
16
+
17
+ def after_reflex(*args, &block)
18
+ add_callback(:after, *args, &block)
19
+ end
20
+
21
+ def around_reflex(*args, &block)
22
+ add_callback(:around, *args, &block)
23
+ end
24
+
25
+ private
26
+
27
+ def add_callback(kind, *args, &block)
28
+ options = args.extract_options!
29
+ options.assert_valid_keys :if, :unless, :only, :except
30
+ set_callback(*[:process, kind, args, normalize_callback_options!(options)].flatten, &block)
31
+ end
32
+
33
+ def normalize_callback_options!(options)
34
+ normalize_callback_option! options, :only, :if
35
+ normalize_callback_option! options, :except, :unless
36
+ options
37
+ end
38
+
39
+ def normalize_callback_option!(options, from, to)
40
+ if (from = options.delete(from))
41
+ from_set = Array(from).map(&:to_s).to_set
42
+ from = proc { |reflex| from_set.include? reflex.method_name }
43
+ options[to] = Array(options[to]).unshift(from)
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end