class-action 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/class_action/version.rb +1 -1
- data/lib/class_action.rb +16 -0
- data/spec/class_action_spec.rb +22 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97c5219d01a0bda05a42c7bb2f0c7c98fc6dd7ed
|
4
|
+
data.tar.gz: 8e0b56fdf6dd1d594b514c56ab08eb2b8651f406
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 035bd987eb5b496d5b2128053e1dfb9a3b7519f20215378d5ce772a6d0cb84e39fe61b9e39208c6ea1bb520fa659c75191d4ba0cac85d54ef50b5e13a555dc63
|
7
|
+
data.tar.gz: ee7bbe117d9d52850bf0ca387c95e6c639e563d4faa998472ac518a98d8ff80c5889d4785c189752b41d2611bdb0cda1fa712df0c79256e82544d00bc01e82c4
|
data/Gemfile.lock
CHANGED
data/lib/class_action/version.rb
CHANGED
data/lib/class_action.rb
CHANGED
@@ -42,6 +42,22 @@ module ClassAction
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
# Delegates the given method to the current class action.
|
46
|
+
def class_action_delegate(*methods)
|
47
|
+
file, line = caller.first.split(':', 2)
|
48
|
+
line = line.to_i
|
49
|
+
|
50
|
+
methods.each do |method|
|
51
|
+
definition = (method =~ /[^\]]=$/) ? 'arg' : '*args, &block'
|
52
|
+
|
53
|
+
module_eval(<<-RUBY, file, line)
|
54
|
+
def #{method}(#{definition})
|
55
|
+
class_action.send :#{method}, #{definition}
|
56
|
+
end
|
57
|
+
RUBY
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
45
61
|
private
|
46
62
|
|
47
63
|
# Injects the mimes (formats) that the action responds to into the controller
|
data/spec/class_action_spec.rb
CHANGED
@@ -189,4 +189,26 @@ describe ClassAction do
|
|
189
189
|
|
190
190
|
end
|
191
191
|
|
192
|
+
describe 'method delegation' do
|
193
|
+
|
194
|
+
it "should allow delegating a method to the current class action" do
|
195
|
+
ClassActionTestController.class_eval do
|
196
|
+
class_action :show
|
197
|
+
class_action_delegate :one, :two
|
198
|
+
end
|
199
|
+
|
200
|
+
action_class = Class.new do
|
201
|
+
def one; :one end
|
202
|
+
def two; :two end
|
203
|
+
protected :two
|
204
|
+
end
|
205
|
+
|
206
|
+
allow(controller).to receive(:class_action).and_return(action_class.new)
|
207
|
+
expect(controller.one).to be(:one)
|
208
|
+
expect(controller.two).to be(:two)
|
209
|
+
expect{controller.three}.to raise_error(NoMethodError)
|
210
|
+
end
|
211
|
+
|
212
|
+
end
|
213
|
+
|
192
214
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: class-action
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joost Lubach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -158,3 +158,4 @@ test_files:
|
|
158
158
|
- spec/class_action/rspec/respond_with_matcher_spec.rb
|
159
159
|
- spec/class_action_spec.rb
|
160
160
|
- spec/spec_helper.rb
|
161
|
+
has_rdoc:
|