Sha256: e8d689d9581ec49eed3ffc8ae5e98bb30d2edf5d74053ea33aef3d50611decf5
Contents?: true
Size: 961 Bytes
Versions: 6
Compression:
Stored size: 961 Bytes
Contents
# frozen_string_literal: true module PagesCore class InviteService include Rails.application.routes.url_helpers attr_reader :attributes, :user, :host, :protocol def initialize(attributes, user:, host:, protocol: "http") @attributes = attributes @user = user @host = host @protocol = protocol end class << self def call(attrs, user:, host:, protocol: "http") new(attrs, user:, host:, protocol:).call end end def call Invite.transaction do invite = user.invites.create(attributes) if invite.valid? deliver_invite(invite) invite.update(sent_at: Time.now.utc) end invite end end private def deliver_invite(invite) AdminMailer.invite( invite, admin_invite_with_token_url(invite, invite.token, host:, protocol:) ).deliver_later end end end
Version data entries
6 entries across 6 versions & 1 rubygems