grape-dsl 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/VERSION +1 -1
- data/grape-dsl.gemspec +1 -1
- data/lib/grape-dsl/mounter.rb +22 -9
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTY2NjJlM2ZmNTgzMjRmNzk1OWY4NDQxZTkwZDIyZDE1NTgzZTEwZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTA3N2M2YzAyMjQ5MzUzMmM2YjU1ZWUxMWE2OGNmNDYwOWI5ZTA1OQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTI3Mjc5ODI2Yzc5ZGVkMTliNzUzODA4MjQzMTk3NTkwNjI3MTk5MmY1YWNh
|
10
|
+
Mjc4OWE0ZDFhZWYzYmJkNjU3ODc5N2VmYzBhODA0OWEyYmJkNDBiMTY0YjIz
|
11
|
+
OTZlYWM5YmI4Njg4MzFmNjljMWU3ZmVjOWNlYTRkMjg0NTAzZmM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTcyMTdiNGNhYjBkYzgyN2NjNTI5Y2Y4MzVmNWIxMmI0ZTJhNTAwNThhMDgw
|
14
|
+
YmQ0Mjg2MDBkMDI3ZmNlZTc5MThhNjI0NTQ1NDFjZTE0YTFhOTJkZDlkMWIw
|
15
|
+
MzhlMjMwMTJiNTEzMTZiMjliNzQ3MDNlN2IzMjQ1OGNmOTNmMWE=
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.1
|
data/grape-dsl.gemspec
CHANGED
data/lib/grape-dsl/mounter.rb
CHANGED
@@ -11,11 +11,14 @@ module Grape
|
|
11
11
|
class << self
|
12
12
|
|
13
13
|
|
14
|
-
# Args
|
14
|
+
# Args will be seperated by they class type
|
15
15
|
# string = path part, will be joined with "/"
|
16
16
|
# hash = options element
|
17
17
|
# Class = target class
|
18
18
|
# Symbol = method name
|
19
|
+
# Proc = These procs will be called with the binding of GrapeEndpoint,
|
20
|
+
# so params and headers Hash::Mash will be allowed to use
|
21
|
+
# they will run BEFORE the method been called, so ideal for auth stuffs
|
19
22
|
#
|
20
23
|
# Array = This is for argument pre parsing, like when you use "hash" and the input will be a json
|
21
24
|
#
|
@@ -27,16 +30,17 @@ module Grape
|
|
27
30
|
# looks like this:
|
28
31
|
# mount_method TestClass, :test_method, "funny_path",:GET
|
29
32
|
#
|
30
|
-
# you can give hash options just like to any
|
33
|
+
# you can give hash options just like to any other get,post put delete etc methods, it will work
|
31
34
|
#
|
32
35
|
def mount_method *args
|
33
36
|
|
34
|
-
options
|
35
|
-
path_name
|
36
|
-
class_name
|
37
|
+
options = Hash[*args.extract_class!(Hash)]
|
38
|
+
path_name = args.extract_class!(String).join('/')
|
39
|
+
class_name = args.extract_class!(Class)[0]
|
40
|
+
before_procs = args.extract_class!(Proc)
|
37
41
|
|
38
|
-
tmp_array
|
39
|
-
adapter_opt
|
42
|
+
tmp_array = args.extract_class!(Array)
|
43
|
+
adapter_opt = Hash.new
|
40
44
|
|
41
45
|
tmp_array.each do |array_obj|
|
42
46
|
if array_obj.count == 2
|
@@ -44,8 +48,8 @@ module Grape
|
|
44
48
|
end
|
45
49
|
end
|
46
50
|
|
47
|
-
method_name
|
48
|
-
rest_method
|
51
|
+
method_name = nil
|
52
|
+
rest_method = nil
|
49
53
|
|
50
54
|
args.extract_class!(Symbol).each do |element|
|
51
55
|
if element.to_s == element.to_s.downcase
|
@@ -58,6 +62,10 @@ module Grape
|
|
58
62
|
rest_method ||= "get"
|
59
63
|
method_obj = class_name.method(method_name).clone
|
60
64
|
|
65
|
+
if path_name == String.new
|
66
|
+
path_name= method_name.to_s
|
67
|
+
end
|
68
|
+
|
61
69
|
|
62
70
|
params do
|
63
71
|
|
@@ -105,7 +113,12 @@ module Grape
|
|
105
113
|
end
|
106
114
|
}-[nil])
|
107
115
|
|
116
|
+
before_procs.each do |proc_obj|
|
117
|
+
proc_obj.call_with_binding self.binding?
|
118
|
+
end
|
119
|
+
|
108
120
|
method_obj.call(*method_arguments)
|
121
|
+
|
109
122
|
end
|
110
123
|
|
111
124
|
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape-dsl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Luzsi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: loader
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ! '>='
|