debian-mirror-gitlab/app/services/user_agent_detail_service.rb
2021-09-30 23:02:18 +05:30

21 lines
580 B
Ruby

# frozen_string_literal: true
class UserAgentDetailService
def initialize(spammable:, spam_params:)
@spammable = spammable
@spam_params = spam_params
end
def create
unless spam_params&.user_agent && spam_params&.ip_address
messasge = 'Skipped UserAgentDetail creation because necessary spam_params were not provided'
return ServiceResponse.success(message: messasge)
end
spammable.create_user_agent_detail(user_agent: spam_params.user_agent, ip_address: spam_params.ip_address)
end
private
attr_reader :spammable, :spam_params
end