interpol 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -61,11 +61,11 @@ module Interpol
61
61
  end
62
62
 
63
63
  def params
64
- @_parsed_params || super
64
+ (@_use_parsed_params && @_parsed_params) || super
65
65
  end
66
66
 
67
67
  def validate_params
68
- @_parsed_params = endpoint_definition.parse_request_params(params_to_parse)
68
+ @_parsed_params ||= endpoint_definition.parse_request_params(params_to_parse)
69
69
  rescue Interpol::ValidationError => error
70
70
  request_params_invalid(error)
71
71
  end
@@ -74,6 +74,14 @@ module Interpol
74
74
  interpol_config.sinatra_request_params_invalid(self, error)
75
75
  end
76
76
 
77
+ def with_parsed_params
78
+ @_use_parsed_params = true
79
+ validate_params if settings.parse_params?
80
+ yield
81
+ ensure
82
+ @_use_parsed_params = false
83
+ end
84
+
77
85
  # Sinatra includes a couple of "meta" params that are always
78
86
  # present in the params hash even though they are not declared
79
87
  # as params: splat and captures.
@@ -93,8 +101,9 @@ module Interpol
93
101
  return super unless SinatraOverriddes.being_processed_by_sinatra?(block)
94
102
 
95
103
  super do |*block_args|
96
- validate_params if settings.parse_params?
97
- yield *block_args
104
+ with_parsed_params do
105
+ yield *block_args
106
+ end
98
107
  end
99
108
  end
100
109
 
@@ -1,3 +1,3 @@
1
1
  module Interpol
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: interpol
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-26 00:00:00.000000000 Z
12
+ date: 2012-10-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json-schema
@@ -223,7 +223,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
223
223
  version: '0'
224
224
  segments:
225
225
  - 0
226
- hash: -2997986651256795952
226
+ hash: -4117955588587785690
227
227
  required_rubygems_version: !ruby/object:Gem::Requirement
228
228
  none: false
229
229
  requirements:
@@ -232,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
232
  version: '0'
233
233
  segments:
234
234
  - 0
235
- hash: -2997986651256795952
235
+ hash: -4117955588587785690
236
236
  requirements: []
237
237
  rubyforge_project:
238
238
  rubygems_version: 1.8.24