padrino-core 0.16.0.pre4 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.rdoc +8 -8
- data/Rakefile +1 -1
- data/bin/padrino +1 -1
- data/lib/padrino-core/application/application_setup.rb +28 -26
- data/lib/padrino-core/application/authenticity_token.rb +3 -2
- data/lib/padrino-core/application/flash.rb +4 -5
- data/lib/padrino-core/application/params_protection.rb +34 -37
- data/lib/padrino-core/application/routing.rb +165 -164
- data/lib/padrino-core/application/show_exceptions.rb +5 -7
- data/lib/padrino-core/application.rb +4 -4
- data/lib/padrino-core/caller.rb +6 -7
- data/lib/padrino-core/cli/adapter.rb +4 -4
- data/lib/padrino-core/cli/base.rb +31 -32
- data/lib/padrino-core/cli/binstub.rb +9 -8
- data/lib/padrino-core/cli/console.rb +1 -1
- data/lib/padrino-core/cli/launcher.rb +45 -42
- data/lib/padrino-core/cli/rake.rb +16 -14
- data/lib/padrino-core/cli/rake_tasks.rb +18 -20
- data/lib/padrino-core/command.rb +1 -1
- data/lib/padrino-core/ext/sinatra.rb +3 -2
- data/lib/padrino-core/filter.rb +3 -3
- data/lib/padrino-core/loader.rb +10 -12
- data/lib/padrino-core/logger.rb +85 -77
- data/lib/padrino-core/mounter/application_extension.rb +2 -2
- data/lib/padrino-core/mounter.rb +33 -34
- data/lib/padrino-core/path_router/compiler.rb +8 -8
- data/lib/padrino-core/path_router/matcher.rb +11 -11
- data/lib/padrino-core/path_router/route.rb +15 -15
- data/lib/padrino-core/path_router.rb +4 -3
- data/lib/padrino-core/reloader/rack.rb +1 -1
- data/lib/padrino-core/reloader/storage.rb +12 -11
- data/lib/padrino-core/reloader.rb +18 -19
- data/lib/padrino-core/router.rb +14 -14
- data/lib/padrino-core/server.rb +20 -24
- data/lib/padrino-core/tasks.rb +0 -1
- data/lib/padrino-core/version.rb +1 -1
- data/lib/padrino-core.rb +9 -10
- data/padrino-core.gemspec +18 -18
- data/test/fixtures/app_gem/app_gem.gemspec +8 -7
- data/test/fixtures/app_gem/lib/app_gem/version.rb +1 -1
- data/test/fixtures/apps/complex.rb +6 -6
- data/test/fixtures/apps/concerned/app.rb +1 -1
- data/test/fixtures/apps/custom_dependencies/custom_dependencies.rb +3 -3
- data/test/fixtures/apps/demo_app.rb +1 -1
- data/test/fixtures/apps/demo_demo.rb +1 -1
- data/test/fixtures/apps/demo_project/api/app.rb +1 -1
- data/test/fixtures/apps/demo_project/app.rb +1 -1
- data/test/fixtures/apps/helpers/class_methods_helpers.rb +1 -0
- data/test/fixtures/apps/helpers/instance_methods_helpers.rb +1 -0
- data/test/fixtures/apps/helpers/system_helpers.rb +0 -1
- data/test/fixtures/apps/lib/myklass/mysubklass.rb +2 -2
- data/test/fixtures/apps/mountable_apps/rack_apps.rb +7 -7
- data/test/fixtures/apps/precompiled_app.rb +6 -5
- data/test/fixtures/apps/simple.rb +5 -5
- data/test/fixtures/apps/static.rb +2 -2
- data/test/fixtures/apps/stealthy/app.rb +1 -1
- data/test/fixtures/apps/stealthy/helpers/stealthy_class_helpers.rb +1 -1
- data/test/fixtures/apps/system.rb +1 -1
- data/test/fixtures/apps/system_class_methods_demo.rb +1 -1
- data/test/fixtures/apps/system_instance_methods_demo.rb +1 -1
- data/test/fixtures/dependencies/a.rb +1 -1
- data/test/fixtures/dependencies/b.rb +1 -1
- data/test/fixtures/dependencies/c.rb +1 -1
- data/test/fixtures/dependencies/circular/e.rb +2 -1
- data/test/fixtures/dependencies/d.rb +1 -1
- data/test/fixtures/dependencies/linear/i.rb +1 -1
- data/test/fixtures/dependencies/nested/l.rb +2 -2
- data/test/fixtures/dependencies/nested/m.rb +1 -1
- data/test/fixtures/dependencies/nested/qqq.rb +2 -2
- data/test/fixtures/dependencies/nested/rrr.rb +1 -1
- data/test/fixtures/dependencies/nested/sss.rb +1 -1
- data/test/fixtures/reloadable_apps/external/app/app.rb +0 -1
- data/test/fixtures/reloadable_apps/external/app/controllers/base.rb +1 -2
- data/test/fixtures/reloadable_apps/main/app.rb +2 -2
- data/test/helper.rb +2 -2
- data/test/test_application.rb +59 -60
- data/test/test_configuration.rb +2 -2
- data/test/test_core.rb +13 -13
- data/test/test_csrf_protection.rb +67 -63
- data/test/test_dependencies.rb +33 -34
- data/test/test_filters.rb +46 -47
- data/test/test_flash.rb +14 -14
- data/test/test_locale.rb +2 -2
- data/test/test_logger.rb +64 -64
- data/test/test_mounter.rb +133 -123
- data/test/test_params_protection.rb +40 -40
- data/test/test_reloader_complex.rb +23 -23
- data/test/test_reloader_external.rb +10 -10
- data/test/test_reloader_simple.rb +26 -23
- data/test/test_reloader_storage.rb +9 -12
- data/test/test_reloader_system.rb +29 -29
- data/test/test_restful_routing.rb +19 -19
- data/test/test_router.rb +126 -145
- data/test/test_routing.rb +882 -894
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 905df870641a62de881388a397652fd8e3b571527f4b716b714dca3a9706cdd3
|
|
4
|
+
data.tar.gz: c3eaaad8dd89f106fdc7a69b2ca30b3fafca57c44cfbbeca7ea2f4b31d602b35
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f07ecd54029247a4fb104223c1c9bc5edd0c3f03ef849d841689cdbccd086a0390c6795f6f0f57b2945eb64ed5ee0e20c002fb09448be1736448ad9c550b9a65
|
|
7
|
+
data.tar.gz: ee2c9d16ca33f397f1a6d4906b958706951d8d170d0cb660a851abff480ca83f313dbaa1a4c113ea94d14da9073f3daf128a0d94c849a87f182f50751ebbb410
|
data/README.rdoc
CHANGED
|
@@ -87,7 +87,7 @@ the padrino framework's functionalities.
|
|
|
87
87
|
Let us first take a look at the simplest possible Padrino application:
|
|
88
88
|
|
|
89
89
|
# app.rb
|
|
90
|
-
PADRINO_ROOT =
|
|
90
|
+
PADRINO_ROOT = __dir__ unless defined? PADRINO_ROOT
|
|
91
91
|
require 'padrino'
|
|
92
92
|
Padrino.load!
|
|
93
93
|
|
|
@@ -114,8 +114,8 @@ within a more structured layout. Simply add a <tt>controllers</tt> or <tt>app/co
|
|
|
114
114
|
|
|
115
115
|
# Simple Example
|
|
116
116
|
SimpleApp.controllers do
|
|
117
|
-
get
|
|
118
|
-
|
|
117
|
+
get '/test' do
|
|
118
|
+
'Text to return'
|
|
119
119
|
end
|
|
120
120
|
end
|
|
121
121
|
|
|
@@ -127,7 +127,7 @@ You can also do more complex route alias definitions:
|
|
|
127
127
|
...
|
|
128
128
|
end
|
|
129
129
|
|
|
130
|
-
get :show, :
|
|
130
|
+
get :show, with: :id do
|
|
131
131
|
# url generated is '/posts/show/:id'
|
|
132
132
|
# access params[:id]
|
|
133
133
|
end
|
|
@@ -141,7 +141,7 @@ as well as mapping the route aliases to an explicit url:
|
|
|
141
141
|
...
|
|
142
142
|
end
|
|
143
143
|
|
|
144
|
-
get :account, :
|
|
144
|
+
get :account, map: '/the/accounts/:name/and/:id' do
|
|
145
145
|
# access params[:name] and params[:index]
|
|
146
146
|
end
|
|
147
147
|
end
|
|
@@ -150,11 +150,11 @@ and even configure the +provides+ for each route:
|
|
|
150
150
|
|
|
151
151
|
# app/controllers/example.rb
|
|
152
152
|
SimpleApp.controllers :admin do
|
|
153
|
-
get :show, :
|
|
153
|
+
get :show, with: :id, provides: :js do
|
|
154
154
|
"Url is /admin/show/#{params[:id]}.#{params[:format]}"
|
|
155
155
|
end
|
|
156
156
|
|
|
157
|
-
get :other, :
|
|
157
|
+
get :other, with: [:id, :name], provides: [:html, :json] do
|
|
158
158
|
case content_type
|
|
159
159
|
when :js then ... end
|
|
160
160
|
when :json then ... end
|
|
@@ -166,7 +166,7 @@ or auto lookup for current locale or content_type
|
|
|
166
166
|
|
|
167
167
|
# app/controllers/example.rb
|
|
168
168
|
SimpleApp.controllers :admin do
|
|
169
|
-
get :show, :
|
|
169
|
+
get :show, with: :id, provides: [:html, :js] do
|
|
170
170
|
render "admin/show"
|
|
171
171
|
end
|
|
172
172
|
end
|
data/Rakefile
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative '../gem_rake_helper'
|
data/bin/padrino
CHANGED
|
@@ -3,7 +3,7 @@ require 'padrino-core/cli/binstub'
|
|
|
3
3
|
Padrino.replace_with_binstub('padrino')
|
|
4
4
|
|
|
5
5
|
padrino_core_path = File.expand_path('../lib', __dir__)
|
|
6
|
-
|
|
6
|
+
$LOAD_PATH.unshift(padrino_core_path) if File.directory?(padrino_core_path) && !$LOAD_PATH.include?(padrino_core_path)
|
|
7
7
|
|
|
8
8
|
require 'padrino-core/cli/base'
|
|
9
9
|
Padrino::Cli::Base.start(ARGV)
|
|
@@ -12,7 +12,7 @@ module Padrino
|
|
|
12
12
|
# Defines default settings for Padrino application.
|
|
13
13
|
#
|
|
14
14
|
def default_configuration!
|
|
15
|
-
set :app_file, File.expand_path(caller_files.first || $
|
|
15
|
+
set :app_file, File.expand_path(caller_files.first || $PROGRAM_NAME)
|
|
16
16
|
set :app_name, Inflections.underscore(settings).to_sym
|
|
17
17
|
|
|
18
18
|
set :environment, Padrino.env
|
|
@@ -66,7 +66,7 @@ module Padrino
|
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
def default_security
|
|
69
|
-
set :protection, :
|
|
69
|
+
set :protection, except: :path_traversal
|
|
70
70
|
set :sessions, false
|
|
71
71
|
set :protect_from_csrf, false
|
|
72
72
|
set :report_csrf_failure, false
|
|
@@ -96,7 +96,7 @@ module Padrino
|
|
|
96
96
|
'/models/**/*.rb',
|
|
97
97
|
'/lib.rb',
|
|
98
98
|
'/lib/**/*.rb'
|
|
99
|
-
].map{ |glob| File.join(settings.root, glob) }
|
|
99
|
+
].map { |glob| File.join(settings.root, glob) }
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
# Overrides the default middleware for Sinatra based on Padrino conventions.
|
|
@@ -122,7 +122,7 @@ module Padrino
|
|
|
122
122
|
configure :development do
|
|
123
123
|
get '*__sinatra__/:image.png' do
|
|
124
124
|
content_type :png
|
|
125
|
-
send_file(
|
|
125
|
+
send_file("#{__dir__}/../images/#{params[:image]}.png")
|
|
126
126
|
end
|
|
127
127
|
end
|
|
128
128
|
end
|
|
@@ -132,15 +132,18 @@ module Padrino
|
|
|
132
132
|
#
|
|
133
133
|
def default_errors
|
|
134
134
|
configure :production do
|
|
135
|
+
return if errors.key?(::Exception)
|
|
136
|
+
|
|
135
137
|
error ::Exception do
|
|
136
138
|
logger.exception env['sinatra.error']
|
|
137
139
|
halt(500, { 'content-type' => 'text/html' }, ['<h1>Internal Server Error</h1>'])
|
|
138
|
-
end
|
|
140
|
+
end
|
|
139
141
|
end
|
|
140
142
|
end
|
|
141
143
|
|
|
142
144
|
def setup_locale
|
|
143
145
|
return unless defined? I18n
|
|
146
|
+
|
|
144
147
|
Reloader.special_files += locale_path
|
|
145
148
|
I18n.load_path << locale_path
|
|
146
149
|
I18n.reload!
|
|
@@ -148,7 +151,7 @@ module Padrino
|
|
|
148
151
|
|
|
149
152
|
# allow custome session management
|
|
150
153
|
def setup_sessions(builder)
|
|
151
|
-
if sessions.
|
|
154
|
+
if sessions.is_a?(Hash) && sessions[:use]
|
|
152
155
|
builder.use sessions[:use], sessions[:config] || {}
|
|
153
156
|
else
|
|
154
157
|
super
|
|
@@ -158,21 +161,20 @@ module Padrino
|
|
|
158
161
|
# sets up csrf protection for the app
|
|
159
162
|
def setup_csrf_protection(builder)
|
|
160
163
|
check_csrf_protection_dependency
|
|
164
|
+
return unless protect_from_csrf?
|
|
161
165
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
builder.use(options[:except] ? Padrino::AuthenticityToken : Rack::Protection::AuthenticityToken, options)
|
|
166
|
-
end
|
|
166
|
+
options = options_for_csrf_protection_setup
|
|
167
|
+
options.merge!(protect_from_csrf) if protect_from_csrf.is_a?(Hash)
|
|
168
|
+
builder.use(options[:except] ? Padrino::AuthenticityToken : Rack::Protection::AuthenticityToken, options)
|
|
167
169
|
end
|
|
168
170
|
|
|
169
171
|
# returns the options used in the builder for csrf protection setup
|
|
170
172
|
def options_for_csrf_protection_setup
|
|
171
|
-
options = { :
|
|
173
|
+
options = { logger: logger }
|
|
172
174
|
if report_csrf_failure? || allow_disabled_csrf?
|
|
173
175
|
options.merge!(
|
|
174
|
-
:
|
|
175
|
-
:
|
|
176
|
+
reaction: :report,
|
|
177
|
+
report_key: 'protection.csrf.failed'
|
|
176
178
|
)
|
|
177
179
|
end
|
|
178
180
|
options
|
|
@@ -180,23 +182,23 @@ module Padrino
|
|
|
180
182
|
|
|
181
183
|
# warn if the protect_from_csrf is active but sessions are not
|
|
182
184
|
def check_csrf_protection_dependency
|
|
183
|
-
|
|
184
|
-
warn(<<-ERROR)
|
|
185
|
-
`protect_from_csrf` is activated, but `sessions` seem to be off. To enable csrf
|
|
186
|
-
protection, use:
|
|
185
|
+
return unless protect_from_csrf? && !sessions? && !defined?(Padrino::IGNORE_CSRF_SETUP_WARNING)
|
|
187
186
|
|
|
188
|
-
|
|
187
|
+
warn(<<~ERROR)
|
|
188
|
+
`protect_from_csrf` is activated, but `sessions` seem to be off. To enable csrf
|
|
189
|
+
protection, use:
|
|
189
190
|
|
|
190
|
-
|
|
191
|
+
enable :sessions
|
|
191
192
|
|
|
192
|
-
|
|
193
|
+
or deactivate protect_from_csrf:
|
|
193
194
|
|
|
194
|
-
|
|
195
|
+
disable :protect_from_csrf
|
|
195
196
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
197
|
+
If you use a different session store, ignore this warning using:
|
|
198
|
+
|
|
199
|
+
# in boot.rb:
|
|
200
|
+
Padrino::IGNORE_CSRF_SETUP_WARNING = true
|
|
201
|
+
ERROR
|
|
200
202
|
end
|
|
201
203
|
end
|
|
202
204
|
end
|
|
@@ -17,9 +17,10 @@ module Padrino
|
|
|
17
17
|
|
|
18
18
|
def except?(env)
|
|
19
19
|
return false unless @except
|
|
20
|
+
return @except.call(env) if @except.is_a?(Proc)
|
|
21
|
+
|
|
20
22
|
path_info = env['PATH_INFO']
|
|
21
|
-
@except.is_a?(
|
|
22
|
-
path.is_a?(Regexp) ? path.match(path_info) : path == path_info }
|
|
23
|
+
@except.any? { |path| path.is_a?(Regexp) ? path.match(path_info) : path == path_info }
|
|
23
24
|
end
|
|
24
25
|
end
|
|
25
26
|
end
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
module Padrino
|
|
2
2
|
module Flash
|
|
3
|
-
|
|
4
3
|
class << self
|
|
5
4
|
def registered(app)
|
|
6
5
|
app.helpers Helpers
|
|
@@ -14,7 +13,7 @@ module Padrino
|
|
|
14
13
|
include Enumerable
|
|
15
14
|
|
|
16
15
|
# @private
|
|
17
|
-
def initialize(session=nil)
|
|
16
|
+
def initialize(session = nil)
|
|
18
17
|
@_now = session || {}
|
|
19
18
|
@_next = {}
|
|
20
19
|
end
|
|
@@ -77,7 +76,7 @@ module Padrino
|
|
|
77
76
|
@_now.update(hash)
|
|
78
77
|
self
|
|
79
78
|
end
|
|
80
|
-
|
|
79
|
+
alias merge! update
|
|
81
80
|
|
|
82
81
|
# @since 0.10.8
|
|
83
82
|
# @api public
|
|
@@ -130,7 +129,7 @@ module Padrino
|
|
|
130
129
|
def length
|
|
131
130
|
@_now.length
|
|
132
131
|
end
|
|
133
|
-
|
|
132
|
+
alias size length
|
|
134
133
|
|
|
135
134
|
# @since 0.10.8
|
|
136
135
|
# @api public
|
|
@@ -212,7 +211,7 @@ module Padrino
|
|
|
212
211
|
|
|
213
212
|
super(url, args)
|
|
214
213
|
end
|
|
215
|
-
|
|
214
|
+
alias redirect_to redirect
|
|
216
215
|
|
|
217
216
|
###
|
|
218
217
|
# Returns the flash storage object.
|
|
@@ -19,21 +19,21 @@ module Padrino
|
|
|
19
19
|
# Implements filtering of url query params. Can prevent mass-assignment.
|
|
20
20
|
#
|
|
21
21
|
# @example
|
|
22
|
-
# post :update, :
|
|
23
|
-
# post :update, :
|
|
24
|
-
# post :update, :
|
|
25
|
-
# post :update, :
|
|
26
|
-
# post :update, :
|
|
27
|
-
# post :update, :
|
|
22
|
+
# post :update, params: [:name, :email]
|
|
23
|
+
# post :update, params: [:name, { id: Integer }]
|
|
24
|
+
# post :update, params: [{ name: proc { |v| v.reverse } }]
|
|
25
|
+
# post :update, params: [:name, { parent: [:name, :position] }]
|
|
26
|
+
# post :update, params: false
|
|
27
|
+
# post :update, params: true
|
|
28
28
|
# @example
|
|
29
|
-
# params :name, :email, :
|
|
29
|
+
# params :name, :email, password: proc { |v| v.reverse }
|
|
30
30
|
# post :update
|
|
31
31
|
# @example
|
|
32
|
-
# App.controller :accounts, :
|
|
32
|
+
# App.controller :accounts, params: [:name, :position] do
|
|
33
33
|
# post :create
|
|
34
|
-
# post :update, :
|
|
35
|
-
# get :show, :
|
|
36
|
-
# get :search, :
|
|
34
|
+
# post :update, with: [:id], params: [:name, :position, :addition]
|
|
35
|
+
# get :show, with: :id, params: false
|
|
36
|
+
# get :search, params: true
|
|
37
37
|
# end
|
|
38
38
|
#
|
|
39
39
|
def params(*allowed_params)
|
|
@@ -48,11 +48,10 @@ module Padrino
|
|
|
48
48
|
|
|
49
49
|
def prepare_allowed_params(allowed_params)
|
|
50
50
|
param_filter = {}
|
|
51
|
-
allowed_params.each do |key,value|
|
|
52
|
-
|
|
53
|
-
when key.kind_of?(Hash) && !value
|
|
51
|
+
allowed_params.each do |key, value|
|
|
52
|
+
if key.is_a?(Hash) && !value
|
|
54
53
|
param_filter.update(prepare_allowed_params(key))
|
|
55
|
-
|
|
54
|
+
elsif value.is_a?(Hash) || value.is_a?(Array)
|
|
56
55
|
param_filter[key.to_s] = prepare_allowed_params(value)
|
|
57
56
|
else
|
|
58
57
|
param_filter[key.to_s] = value == false ? false : (value || true)
|
|
@@ -75,38 +74,36 @@ module Padrino
|
|
|
75
74
|
# scalar classes are: Integer (empty string is cast to nil).
|
|
76
75
|
#
|
|
77
76
|
# @example
|
|
78
|
-
# filter_params!( {
|
|
79
|
-
# {
|
|
80
|
-
# # => {
|
|
81
|
-
# filter_params!( {
|
|
82
|
-
# {
|
|
83
|
-
# # => {
|
|
84
|
-
# filter_params!( {
|
|
85
|
-
# {
|
|
86
|
-
# # => {
|
|
87
|
-
# filter_params!( {
|
|
88
|
-
# {
|
|
89
|
-
# # => {
|
|
77
|
+
# filter_params!( { 'a' => '1', 'b' => 'abc', 'd' => 'drop' },
|
|
78
|
+
# { 'a' => Integer, 'b' => true } )
|
|
79
|
+
# # => { 'a' => 1, 'b' => 'abc' }
|
|
80
|
+
# filter_params!( { 'id' => '', 'child' => { 'name' => 'manny' } },
|
|
81
|
+
# { 'id' => Integer, 'child' => { 'name' => proc{ |v| v.camelize } } } )
|
|
82
|
+
# # => { 'id' => nil, 'child' => { 'name' => 'Manny' } }
|
|
83
|
+
# filter_params!( { 'a' => ['1', '2', '3'] },
|
|
84
|
+
# { 'a' => true } )
|
|
85
|
+
# # => { 'a' => ['1', '2', '3'] }
|
|
86
|
+
# filter_params!( { 'persons' => { 'p-1' => { 'name' => 'manny', 'age' => '50' }, 'p-2' => { 'name' => 'richard', 'age' => '50' } } },
|
|
87
|
+
# { 'persons' => { 'name' => true } } )
|
|
88
|
+
# # => { 'persons' => { 'p-1' => { 'name' => 'manny' }, 'p-2' => { 'name' => 'richard' } } }
|
|
90
89
|
#
|
|
91
90
|
def filter_params!(params, allowed_params)
|
|
92
|
-
params.each do |key,value|
|
|
91
|
+
params.each do |key, value|
|
|
93
92
|
type = allowed_params[key]
|
|
94
|
-
next if value.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
value.each do |array_index,array_value|
|
|
93
|
+
next if value.is_a?(Array) && type
|
|
94
|
+
if type.is_a?(Hash) && value.is_a?(Hash)
|
|
95
|
+
if key == Inflections.pluralize(key) && value.values.first.is_a?(Hash)
|
|
96
|
+
value.each do |array_index, array_value|
|
|
99
97
|
value[array_index] = filter_params!(array_value, type)
|
|
100
98
|
end
|
|
101
99
|
else
|
|
102
100
|
params[key] = filter_params!(value, type)
|
|
103
101
|
end
|
|
104
|
-
|
|
102
|
+
elsif type == Integer
|
|
105
103
|
params[key] = value.empty? ? nil : value.to_i
|
|
106
|
-
|
|
104
|
+
elsif type.is_a?(Proc)
|
|
107
105
|
params[key] = type.call(value)
|
|
108
|
-
|
|
109
|
-
else
|
|
106
|
+
elsif type != true
|
|
110
107
|
params.delete(key)
|
|
111
108
|
end
|
|
112
109
|
end
|