[refs #733] small refactoring
This commit is contained in:
parent
663db6e7ff
commit
b8e6903faa
|
@ -52,13 +52,14 @@ class Api::V1::BuildListsController < Api::V1::BaseController
|
||||||
private
|
private
|
||||||
|
|
||||||
def render_json(action_name)
|
def render_json(action_name)
|
||||||
if !@build_list.send "can_#{action_name}?"
|
res, message = if !@build_list.send "can_#{action_name}?"
|
||||||
render :json => {:"is_#{action_name}ed" => false, :url => api_v1_build_list_path(@build_list, :format => :json), :message => "Incorrect action for current status"}
|
[false, "Incorrect action for current status"]
|
||||||
elsif @build_list.send(action_name)
|
elsif @build_list.send(action_name)
|
||||||
render :json => {:"is_#{action_name}ed" => true, :url => api_v1_build_list_path(@build_list, :format => :json), :message => t("layout.build_lists.#{action_name}_success")}
|
[true, t("layout.build_lists.#{action_name}_success")]
|
||||||
else
|
else
|
||||||
render :json => {:"is_#{action_name}ed" => false, :url => api_v1_build_list_path(@build_list, :format => :json), :message => t("layout.build_lists.#{action_name}_fail")}
|
[false, t("layout.build_lists.#{action_name}_fail")]
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
render :json => {:"is_#{action_name}ed" => res, :url => api_v1_build_list_path(@build_list, :format => :json), :message => message}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue