Add method to API::Variables for filtering params
This allows EE to customize the parameters used in two places, without having to modify the source code directly.
This commit is contained in:
parent
3f629b8d14
commit
a7004e2825
1 changed files with 10 additions and 0 deletions
|
@ -7,6 +7,14 @@ module API
|
|||
before { authenticate! }
|
||||
before { authorize! :admin_build, user_project }
|
||||
|
||||
helpers do
|
||||
def filter_variable_parameters(params)
|
||||
# This method exists so that EE can more easily filter out certain
|
||||
# parameters, without having to modify the source code directly.
|
||||
params
|
||||
end
|
||||
end
|
||||
|
||||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
|
@ -50,6 +58,7 @@ module API
|
|||
end
|
||||
post ':id/variables' do
|
||||
variable_params = declared_params(include_missing: false)
|
||||
variable_params = filter_variable_parameters(variable_params)
|
||||
|
||||
variable = user_project.variables.create(variable_params)
|
||||
|
||||
|
@ -75,6 +84,7 @@ module API
|
|||
break not_found!('Variable') unless variable
|
||||
|
||||
variable_params = declared_params(include_missing: false).except(:key)
|
||||
variable_params = filter_variable_parameters(variable_params)
|
||||
|
||||
if variable.update(variable_params)
|
||||
present variable, with: Entities::Variable
|
||||
|
|
Loading…
Reference in a new issue