Sha256: 360c4411f2e2cd504f6635f3077307bb2ce69a968e58f984b303b8f83c53412e
Contents?: true
Size: 769 Bytes
Versions: 7
Compression:
Stored size: 769 Bytes
Contents
# frozen_string_literal: true module PagesCore class CreateUserService attr_reader :attributes, :invite def initialize(attributes, invite: nil) @attributes = attributes @invite = invite end class << self def call(attrs, invite: nil) new(attrs, invite:).call end end def call User.transaction do user = User.create(attributes.merge(invite_attributes)) if user.valid? PagesCore::PubSub.publish(:create_user, user:, invite:) invite&.destroy end user end end private def invite_attributes return {} unless invite { role_names: invite.role_names, creator: invite.user, activated: true } end end end
Version data entries
7 entries across 7 versions & 1 rubygems