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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/disel_router.rb +19 -6
  3. metadata +5 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cadf0476c76bedaa2d49919f0ed6a3987fc082bc
4
- data.tar.gz: ef304e2dc63aa2187679be03304356484c34a3cd
3
+ metadata.gz: 8d6e3b26542f33da84cf3139a1a0f665b7382b28
4
+ data.tar.gz: 21db9edc61cb44a2594380992f3975b95cfc140f
5
5
  SHA512:
6
- metadata.gz: 658904e9b540103908894ad42f2b41831bbe2495ae3ae337f846b448e36e87249cd9af33fab9c2a30384a00f7ff1f32a849fc5e8781cb9df6ddb1ca1174d744e
7
- data.tar.gz: d7d09cd1bcd7c9f76f1f73956008c33822bc21a95e1a1f9d3482b2f2ebbdfd59c3812f523518226246cb87b3e2d0a4ab67f5d904ac1e2a09bd0fa05008d20d39
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(http_method, path, method)
21
+ def m.route(http_verb, *args, controller_method)
9
22
  routes = ROUTES[self]
10
23
  if routes.nil?
11
- ROUTES[self] = Hash.new
24
+ ROUTES[self] = []
12
25
  routes = ROUTES[self]
13
26
  end
14
- routes[http_method] = [path, method]
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 |http_method, arr|
20
- controller.send(http_method, arr.first) do |*args|
21
- self.send(arr.last, *args)
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.1
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-05 00:00:00.000000000 Z
11
+ date: 2016-05-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Allows you to define your routes in separate modules and them mix them
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: Utility mixin for separating your Sinatra routes from controllers
44
+ summary: Separates your Sinatra routes from controllers
45
45
  test_files: []