Module: Sinatra::AcceptParams::Helpers
- Defined in:
- lib/sinatra/accept_params/helpers.rb
Instance Method Summary collapse
-
#accept_no_params(opts = {}) ⇒ Object
Shortcut functions to tighten up security further.
- #accept_only_id(opts = {}) ⇒ Object
-
#accept_params(opts = {}) {|rules| ... } ⇒ Object
:yields: param.
Instance Method Details
#accept_no_params(opts = {}) ⇒ Object
Shortcut functions to tighten up security further
14 15 16 |
# File 'lib/sinatra/accept_params/helpers.rb', line 14 def accept_no_params(opts={}) accept_params(opts) {} end |
#accept_only_id(opts = {}) ⇒ Object
18 19 20 21 22 |
# File 'lib/sinatra/accept_params/helpers.rb', line 18 def accept_only_id(opts={}) accept_params(opts) do |p| p.integer :id, :required => true end end |
#accept_params(opts = {}) {|rules| ... } ⇒ Object
:yields: param
5 6 7 8 9 10 11 |
# File 'lib/sinatra/accept_params/helpers.rb', line 5 def accept_params(opts={}, &block) #:yields: param raise NoParamsDefined, "Missing block for accept_params" unless block_given? rules = ParamRules.new(opts) rules.validate_request(request, session) yield rules rules.validate(params) end |