disel_router 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/disel_router.rb +19 -6
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d6e3b26542f33da84cf3139a1a0f665b7382b28
|
4
|
+
data.tar.gz: 21db9edc61cb44a2594380992f3975b95cfc140f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87e9fd41e66b6089a13c165f2ce6a05fc62fadbf34bc6eb5c441d9fbafe437fb9176bf229a91a18be6946addd1adcc20d6971d036e6093b002e62511872c8616
|
7
|
+
data.tar.gz: 75422e7264209f63f98d825708d437f1c1f5fb8bfa9d160b748bf2032068e65d0f4031d2c0a9da31f3dbc92fb3de9437654c46fde14a804499e16fd293d4ce44
|
data/lib/disel_router.rb
CHANGED
@@ -1,24 +1,37 @@
|
|
1
1
|
module Disel
|
2
|
+
|
3
|
+
class Route
|
4
|
+
attr_reader :verb
|
5
|
+
attr_reader :args
|
6
|
+
attr_reader :method
|
7
|
+
|
8
|
+
def initialize(http_method, args, controller_method)
|
9
|
+
@verb = http_method
|
10
|
+
@method = controller_method
|
11
|
+
@args = args
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
2
15
|
module Router
|
3
16
|
ROUTES = Hash.new
|
4
17
|
|
5
18
|
def self.included(mod)
|
6
19
|
mod.module_eval do |m|
|
7
20
|
|
8
|
-
def m.route(
|
21
|
+
def m.route(http_verb, *args, controller_method)
|
9
22
|
routes = ROUTES[self]
|
10
23
|
if routes.nil?
|
11
|
-
ROUTES[self] =
|
24
|
+
ROUTES[self] = []
|
12
25
|
routes = ROUTES[self]
|
13
26
|
end
|
14
|
-
routes
|
27
|
+
routes << Route.new(http_verb, args, controller_method)
|
15
28
|
end
|
16
29
|
|
17
30
|
def m.included(controller)
|
18
31
|
routes = ROUTES[self]
|
19
|
-
routes.each do |
|
20
|
-
controller.send(
|
21
|
-
self.send(
|
32
|
+
routes.each do |route|
|
33
|
+
controller.send(route.verb, *route.args) do |*args|
|
34
|
+
self.send(route.method, *args)
|
22
35
|
end
|
23
36
|
end
|
24
37
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: disel_router
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yury Solovyov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: Allows you to define
|
14
|
-
into controllers
|
13
|
+
description: Allows you to define application routes in separate modules and then
|
14
|
+
mix them into controllers
|
15
15
|
email: biohazard707@gmail.com
|
16
16
|
executables: []
|
17
17
|
extensions: []
|
@@ -41,5 +41,5 @@ rubyforge_project:
|
|
41
41
|
rubygems_version: 2.4.8
|
42
42
|
signing_key:
|
43
43
|
specification_version: 4
|
44
|
-
summary:
|
44
|
+
summary: Separates your Sinatra routes from controllers
|
45
45
|
test_files: []
|