From ccfa1352641d8233077015b79a85a0e9f09eaa32 Mon Sep 17 00:00:00 2001 From: Ian Vaughan Date: Thu, 3 Oct 2019 23:57:34 +0100 Subject: [PATCH] Reduce line code to please Rubocop (#111) Fixes #58 --- .../api/v1/inbox_members_controller.rb | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/v1/inbox_members_controller.rb b/app/controllers/api/v1/inbox_members_controller.rb index 6078b1181..93476de88 100644 --- a/app/controllers/api/v1/inbox_members_controller.rb +++ b/app/controllers/api/v1/inbox_members_controller.rb @@ -10,12 +10,8 @@ class Api::V1::InboxMembersController < Api::BaseController # the new ones are the agents which are to be added to the inbox if @inbox begin - agents_to_be_added_ids.each do |user_id| - @inbox.add_member(user_id) - end - agents_to_be_removed_ids.each do |user_id| - @inbox.remove_member(user) - end + add_agents + remove_agents head :ok rescue => e render_could_not_create_error("Could not add agents to inbox") @@ -31,6 +27,18 @@ class Api::V1::InboxMembersController < Api::BaseController private + def add_agents + agents_to_be_added_ids.each do |user_id| + @inbox.add_member(user_id) + end + end + + def remove_agents + agents_to_be_removed_ids.each do |user_id| + @inbox.remove_member(user) + end + end + def agents_to_be_added_ids params[:user_ids] - @current_agents_ids end