monty 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/monty.rb +1 -1
  2. data/lib/monty/delivery.rb +11 -4
  3. metadata +3 -3
@@ -6,7 +6,7 @@ module Monty
6
6
  class << self
7
7
  # App version
8
8
  def version
9
- '0.2.0'
9
+ '0.3.0'
10
10
  end
11
11
 
12
12
  # @return [Regexp] with \A \z boundaries
@@ -30,18 +30,18 @@ module Monty
30
30
 
31
31
  @access_rights_regex = Monty.regex(@access_rights)
32
32
 
33
- @access_rights_regex.match(@path) || verb_match?
33
+ @access_rights_regex.match(@path) || method_match?
34
34
  end
35
35
 
36
36
  private
37
37
 
38
- # Methods like create and update are determined by the HTTP verb.
38
+ # Actions like create and update are determined by the HTTP method.
39
39
  # If the request is against the root resource path and the REQUEST_METHOD
40
40
  # is POST, determine if the user has access rights to /create or
41
41
  # /update (if _method=put)
42
42
  #
43
- # @return [true|false] if request is allowed when considering the HTTP verb
44
- def verb_match?
43
+ # @return [true|false] if request is allowed when considering the HTTP method
44
+ def method_match?
45
45
 
46
46
  return false if @method == :get || !Monty::Resource.regex.match(@path)
47
47
 
@@ -50,6 +50,8 @@ module Monty
50
50
  if @method == :post
51
51
  if put?
52
52
  @access_rights_regex.match("#{@path}update")
53
+ elsif delete?
54
+ @access_rights_regex.match("#{@path}destroy")
53
55
  else
54
56
  @access_rights_regex.match("#{@path}create")
55
57
  end
@@ -61,6 +63,11 @@ module Monty
61
63
  request_query_params.include?('_method=put')
62
64
  end
63
65
 
66
+ # In Rails, :delete method is determined by _method parameter
67
+ def delete?
68
+ request_query_params.include?('_method=delete')
69
+ end
70
+
64
71
  # Set request_query_params instance variable if not set
65
72
  def request_query_params
66
73
  @request_query_params ||= parse_request_query_params
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
7
+ - 3
8
8
  - 0
9
- version: 0.2.0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - stonean
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-19 00:00:00 -04:00
17
+ date: 2010-05-20 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency