Class: Decidim::DirectVerifications::RegisterUser

Inherits:
Object
  • Object
show all
Defined in:
lib/decidim/direct_verifications/register_user.rb

Instance Method Summary collapse

Constructor Details

#initialize(email, data, organization, current_user, instrumenter) ⇒ RegisterUser

Returns a new instance of RegisterUser.



6
7
8
9
10
11
12
# File 'lib/decidim/direct_verifications/register_user.rb', line 6

def initialize(email, data, organization, current_user, instrumenter)
  @email = email
  @name = data.is_a?(Hash) ? data[:name] : data
  @organization = organization
  @current_user = current_user
  @instrumenter = instrumenter
end

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/decidim/direct_verifications/register_user.rb', line 14

def call
  return if user

  InviteUser.call(form) do
    on(:ok) do
      instrumenter.track(:registered, email, user)
    end
    on(:invalid) do
      instrumenter.track(:registered, email)
    end
  end
rescue StandardError => e
  instrumenter.track(:registered, email)
  raise e if Rails.env.test? || Rails.env.development?
end