exposure 0.1.2 → 0.1.3
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.
- data/VERSION +1 -1
- data/lib/exposure/behaviors/callbacks.rb +4 -4
- data/spec/callbacks_spec.rb +14 -0
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
@@ -32,14 +32,14 @@ module Exposure
|
|
32
32
|
|
33
33
|
options[:if] ||= []
|
34
34
|
|
35
|
-
only_methods = options.delete(:only)
|
36
|
-
except_methods = options.delete(:except)
|
35
|
+
only_methods = Array.wrap(options.delete(:only))
|
36
|
+
except_methods = Array.wrap(options.delete(:except))
|
37
37
|
|
38
|
-
if only_methods
|
38
|
+
if only_methods.any?
|
39
39
|
options[:if] << Proc.new {|c| only_methods.include?(c.action_name.intern) }
|
40
40
|
end
|
41
41
|
|
42
|
-
if except_methods
|
42
|
+
if except_methods.any?
|
43
43
|
options[:if] << Proc.new {|c| !except_methods.include?(c.action_name.intern) }
|
44
44
|
end
|
45
45
|
|
data/spec/callbacks_spec.rb
CHANGED
@@ -43,4 +43,18 @@ describe "callbacks'", :type => :controller do
|
|
43
43
|
get(:new)
|
44
44
|
should assign_to(:callback_called).with(3)
|
45
45
|
end
|
46
|
+
|
47
|
+
it "can call callbacks for specific formats as an array" do
|
48
|
+
PiratesController.after :assign, :first_callback_called, :second_callback_called, :only => [:create, :new]
|
49
|
+
PiratesController.after :assign, :third_callback_called, :except => [:new]
|
50
|
+
get(:new)
|
51
|
+
should assign_to(:callback_called).with(2)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "can call callbacks for a specific format as symbol" do
|
55
|
+
PiratesController.after :assign, :first_callback_called, :second_callback_called, :only => :new
|
56
|
+
PiratesController.after :assign, :third_callback_called, :except => :new
|
57
|
+
get(:new)
|
58
|
+
should assign_to(:callback_called).with(2)
|
59
|
+
end
|
46
60
|
end
|