Sha256: 5f6a6f73c13243cea56d3cce3b3d8c775daccdaebec0b657ebc2c78356f51be2
Contents?: true
Size: 994 Bytes
Versions: 21
Compression:
Stored size: 994 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: user, host: host, protocol: 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: host, protocol: protocol) ).deliver_later end end end
Version data entries
21 entries across 21 versions & 1 rubygems
Version | Path |
---|---|
pages_core-3.8.0 | app/services/pages_core/invite_service.rb |