Rubocop autocorrect

This commit is contained in:
Martin Lensment 2014-08-25 14:14:25 +03:00
parent f8c48a7456
commit 6c5c0b38c8
59 changed files with 533 additions and 546 deletions

View file

@ -12,7 +12,7 @@ module Epp::Common
end
def proxy
@svTRID = "ccReg-#{'%010d' % rand(10 ** 10)}"
@svTRID = "ccReg-#{'%010d' % rand(10**10)}"
send(params[:command])
end
@ -36,7 +36,7 @@ module Epp::Common
@current_epp_user ||= EppUser.find(epp_session[:epp_user_id]) if epp_session[:epp_user_id]
end
def handle_errors(obj=nil)
def handle_errors(obj = nil)
@errors ||= []
if obj
obj.construct_epp_errors
@ -44,7 +44,7 @@ module Epp::Common
end
# for debugging
@errors << {code: '1', msg: 'handle_errors was executed when there were actually no errors'} if @errors.blank?
@errors << { code: '1', msg: 'handle_errors was executed when there were actually no errors' } if @errors.blank?
render '/epp/error'
end
@ -55,13 +55,13 @@ module Epp::Common
def xml_attrs_present?(ph, attributes)
attributes.each do |x|
epp_errors << {code: '2003', msg: I18n.t('errors.messages.required_parameter_missing', key: x.last)} unless has_attribute(ph, x)
epp_errors << { code: '2003', msg: I18n.t('errors.messages.required_parameter_missing', key: x.last) } unless has_attribute(ph, x)
end
epp_errors.empty?
end
def has_attribute(ph, path)
path.inject(ph) do |location, key|
path.reduce(ph) do |location, key|
location.respond_to?(:keys) ? location[key] : nil
end
end

View file

@ -1,8 +1,8 @@
module Shared::UserStamper
extend ActiveSupport::Concern
def stamp obj
return false if obj.nil? || !obj.has_attribute?( :created_by_id && :updated_by_id )
def stamp(obj)
return false if obj.nil? || !obj.has_attribute?(:created_by_id && :updated_by_id)
if obj.new_record?
obj.created_by_id = current_epp_user.id
@ -10,6 +10,6 @@ module Shared::UserStamper
obj.updated_by_id = current_epp_user.id
end
return true
end
true
end
end

View file

@ -5,6 +5,7 @@ class Epp::CommandsController < ApplicationController
include Shared::UserStamper
private
def create
send("create_#{OBJECT_TYPES[params_hash['epp']['xmlns:ns2']]}")
end

View file

@ -2,7 +2,7 @@ class Epp::ErrorsController < ApplicationController
include Epp::Common
def error
epp_errors << {code: params[:code], msg: params[:msg]}
epp_errors << { code: params[:code], msg: params[:msg] }
render '/epp/error'
end
end

View file

@ -2,6 +2,7 @@ class Epp::SessionsController < ApplicationController
include Epp::Common
private
def hello
render 'greeting'
end

View file

@ -16,11 +16,12 @@ class SettingGroupsController < ApplicationController
end
private
def set_setting_group
@setting_group = SettingGroup.find(params[:id])
end
def setting_group_params
params.require(:setting_group).permit(settings_attributes: [ :value, :id ])
params.require(:setting_group).permit(settings_attributes: [:value, :id])
end
end