routable 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -0
- data/lib/routable/router.rb +8 -1
- data/lib/routable/version.rb +1 -1
- data/spec/main_spec.rb +10 -0
- metadata +1 -1
data/README.md
CHANGED
data/lib/routable/router.rb
CHANGED
@@ -77,7 +77,14 @@ module Routable
|
|
77
77
|
controller_options = options_for_url(url)
|
78
78
|
|
79
79
|
if controller_options[:callback]
|
80
|
-
controller_options[:
|
80
|
+
params = controller_options[:open_params]
|
81
|
+
callback = controller_options[:callback]
|
82
|
+
case callback.arity
|
83
|
+
when 0
|
84
|
+
callback.call
|
85
|
+
when 1
|
86
|
+
callback.call(params)
|
87
|
+
end
|
81
88
|
return
|
82
89
|
end
|
83
90
|
|
data/lib/routable/version.rb
CHANGED
data/spec/main_spec.rb
CHANGED
@@ -111,4 +111,14 @@ describe "the url router" do
|
|
111
111
|
@router.open("logout")
|
112
112
|
@called.should == true
|
113
113
|
end
|
114
|
+
|
115
|
+
it "should work with callback blocks & params" do
|
116
|
+
@called = false
|
117
|
+
@router.map("logout/:id") do |params|
|
118
|
+
@called = params[:id]
|
119
|
+
end
|
120
|
+
|
121
|
+
@router.open("logout/123")
|
122
|
+
@called.should == "123"
|
123
|
+
end
|
114
124
|
end
|