Sha256: 6453fab054d732e64ac4be5db361029323392eb6d0f1e5d802a6f3e893e8a27e

Contents?: true

Size: 592 Bytes

Versions: 8

Compression:

Stored size: 592 Bytes

Contents

# frozen_string_literal: true

module PUNK
  class CreateIdentitiesService < Service
    def process
      User.each do |user|
        if user.email.present?
          Identity.find_or_create(claim: user.email) do |i|
            i.claim_type = :email
            i.user = user
          end
        end
        if user.phone.present?
          Identity.find_or_create(claim: user.phone) do |i|
            i.claim_type = :phone
            i.user = user
          end
        end
      rescue Sequel::ValidationFailed => e
        logger.warn e.message
      end
      nil
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
punk-0.4.1 lib/punk/services/create_identities.rb
punk-0.3.6 lib/punk/services/create_identities.rb
punk-0.3.5 lib/punk/services/create_identities.rb
punk-0.3.4 lib/punk/services/create_identities.rb
punk-0.3.3 lib/punk/services/create_identities.rb
punk-0.3.2 lib/punk/services/create_identities.rb
punk-0.3.1 lib/punk/services/create_identities.rb
punk-0.2.0 lib/punk/services/create_identities.rb