| Module | Merb::ParamsFilter::RequestMixin |
| In: |
merb-param-protection/lib/merb-param-protection.rb
|
| trashed_params | [RW] |
Removes specified parameters of an object
remove_params_from_object(:post, [:status, :author_id])
# File merb-param-protection/lib/merb-param-protection.rb, line 133
133: def remove_params_from_object(obj, attrs = [])
134: unless params[obj].nil?
135: filtered = params
136: attrs.each {|a| filtered[obj].delete(a)}
137: @params = filtered
138: end
139: end
Restricts parameters of an object
restrict_params(:post, [:title, :body])
# File merb-param-protection/lib/merb-param-protection.rb, line 145
145: def restrict_params(obj, attrs = [])
146: # Make sure the params for the object exists
147: unless params[obj].nil?
148: attrs = attrs.collect {|a| a.to_s}
149: trashed_params_keys = params[obj].keys - attrs
150:
151: # Store a hash of the key/value pairs we are going
152: # to remove in case we need them later. Lighthouse Bug # 105
153: @trashed_params = {}
154: trashed_params_keys.each do |key|
155: @trashed_params.merge!({key => params[obj][key]})
156: end
157:
158: remove_params_from_object(obj, trashed_params_keys)
159: end
160: end