rutter 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -1
- data/lib/rutter/routes.rb +8 -2
- data/lib/rutter/version.rb +1 -1
- data/spec/unit/routes_spec.rb +7 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f91432538209a198ac676ddfe072b83d469b382
|
4
|
+
data.tar.gz: b8fb9fe0e6ff41ccfb91b30fe34b67a189b89c38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f66d79b45f86bf37aad68fa4a0374b8594d954711fef0de1b4ca738acb1e4d48269d2d16d14a85cbcda6e3a35fbddfa0fe58b3ceb04e5faa40c084fbd0081ba3
|
7
|
+
data.tar.gz: ee48cfa27b6d7e9fe557f108eeb48fab5f32647d9c4a0ee4fa7cddb6baeda25233da0e78da58b5bd79693f70f112bb56a19b2b921a54ca0a9c7efeca5b8d337d
|
data/.rubocop.yml
CHANGED
data/lib/rutter/routes.rb
CHANGED
@@ -26,10 +26,16 @@ module Rutter
|
|
26
26
|
protected
|
27
27
|
|
28
28
|
# @private
|
29
|
-
def method_missing(
|
30
|
-
named_route, type =
|
29
|
+
def method_missing(method_name, *args)
|
30
|
+
named_route, type = method_name.to_s.split(/\_(path|url)\z/)
|
31
31
|
return super unless type
|
32
32
|
@builder.public_send(type, named_route.to_sym, *args)
|
33
33
|
end
|
34
|
+
|
35
|
+
# @private
|
36
|
+
def respond_to_missing?(method_name, include_private = false)
|
37
|
+
meth = method_name.to_s
|
38
|
+
meth.end_with?("_path") || meth.end_with?("_url") || super
|
39
|
+
end
|
34
40
|
end
|
35
41
|
end
|
data/lib/rutter/version.rb
CHANGED
data/spec/unit/routes_spec.rb
CHANGED
@@ -25,5 +25,12 @@ module Rutter
|
|
25
25
|
it "raises NoMethodError if unknown method is called" do
|
26
26
|
assert_raises(NoMethodError) { routes.invalid }
|
27
27
|
end
|
28
|
+
|
29
|
+
it "support respond_to?" do
|
30
|
+
router.get "/books/:id", to: "Books#show", as: :book
|
31
|
+
refute routes.respond_to?(:book)
|
32
|
+
assert routes.respond_to?(:book_path)
|
33
|
+
assert routes.respond_to?(:book_url)
|
34
|
+
end
|
28
35
|
end
|
29
36
|
end
|