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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTVjYzEwMjMxMmJhNDAyMzg4ODk5YjhlYjE4YWNjMzhlOTc0MzEzOQ==
4
+ MTY2NjJlM2ZmNTgzMjRmNzk1OWY4NDQxZTkwZDIyZDE1NTgzZTEwZg==
5
5
  data.tar.gz: !binary |-
6
- ZTBlNDAwZTk2YjE2YjA1MGE1YzliOGVjYjUzZjI2MDU3ZGI0NDk3Yg==
6
+ YTA3N2M2YzAyMjQ5MzUzMmM2YjU1ZWUxMWE2OGNmNDYwOWI5ZTA1OQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTE0ZmVmMzIwYmJmMmJhNDVkYWIwNzI2NDhmYjljMjdmNDI0NDFjN2JhYjhk
10
- ZjU2MzZjODZhODBiYzhkMjYxODZhMWE0NTA0N2I0MmU1YmFjYTg2YjJiYTNm
11
- YTQ2ZDhkMGY1MGJkMjE5MTVhMjE3NzA1ZjQ2OWQ3YTE0OGE0YTM=
9
+ ZTI3Mjc5ODI2Yzc5ZGVkMTliNzUzODA4MjQzMTk3NTkwNjI3MTk5MmY1YWNh
10
+ Mjc4OWE0ZDFhZWYzYmJkNjU3ODc5N2VmYzBhODA0OWEyYmJkNDBiMTY0YjIz
11
+ OTZlYWM5YmI4Njg4MzFmNjljMWU3ZmVjOWNlYTRkMjg0NTAzZmM=
12
12
  data.tar.gz: !binary |-
13
- Y2NmZjI2NDZlYzUwYTM3YTA1MTBlYzNkNGNkNjlhMWQ4YzE0MWQ4MTk0MmRi
14
- ZDYzOTY4OGM5ZWJkOGI4ODNmMjEwYzFjM2NmOGE3NjdjNjlmODljM2JkNTIz
15
- NjAxY2IxY2FiZjgxMTRjMzA5NjE2MGUzNDk2NzRmZjI1Yjg2OGU=
13
+ OTcyMTdiNGNhYjBkYzgyN2NjNTI5Y2Y4MzVmNWIxMmI0ZTJhNTAwNThhMDgw
14
+ YmQ0Mjg2MDBkMDI3ZmNlZTc5MThhNjI0NTQ1NDFjZTE0YTFhOTJkZDlkMWIw
15
+ MzhlMjMwMTJiNTEzMTZiMjliNzQ3MDNlN2IzMjQ1OGNmOTNmMWE=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.0
1
+ 1.2.1
data/grape-dsl.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency "procemon"
22
+ spec.add_dependency "loader"
23
23
  spec.add_dependency "grape"
24
24
 
25
25
  end
@@ -11,11 +11,14 @@ module Grape
11
11
  class << self
12
12
 
13
13
 
14
- # Args description
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 othere get,post put delete etc methods, it will work
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 = Hash[*args.extract_class!(Hash)]
35
- path_name = args.extract_class!(String).join('/')
36
- class_name = args.extract_class!(Class)[0]
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 = args.extract_class!(Array)
39
- adapter_opt = Hash.new
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 = nil
48
- rest_method = nil
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.0
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-10 00:00:00.000000000 Z
11
+ date: 2014-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: procemon
14
+ name: loader
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ! '>='