From b8b03b62b0dfa9f870de38d3651f749f73e75db2 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Thu, 31 Jan 2013 00:51:05 +0400 Subject: [PATCH] #859: small refactoring --- app/controllers/api/v1/build_lists_controller.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/controllers/api/v1/build_lists_controller.rb b/app/controllers/api/v1/build_lists_controller.rb index 72e77dd53..6a747556a 100644 --- a/app/controllers/api/v1/build_lists_controller.rb +++ b/app/controllers/api/v1/build_lists_controller.rb @@ -42,17 +42,13 @@ class Api::V1::BuildListsController < Api::V1::BaseController end def create_container - if @build_list.can_create_container? && @build_list.publish_container - render_json_response @build_list, t('layout.build_lists.create_container_success') - else - render_validation_error @build_list, t('layout.build_lists.create_container_fail') - end + render_json :create_container, :publish_container end private - def render_json(action_name) - if @build_list.try("can_#{action_name}?") && @build_list.send(action_name) + def render_json(action_name, action_method = nil) + if @build_list.try("can_#{action_name}?") && @build_list.send(action_method || action_name) render_json_response @build_list, t("layout.build_lists.#{action_name}_success") else render_validation_error @build_list, t("layout.build_lists.#{action_name}_fail")