Class: Artisan::Notifications::Inviter

Inherits:
Object
  • Object
show all
Defined in:
lib/artisan/notifications/inviter.rb

Constant Summary collapse

EMAIL_REGEX =
/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/

Instance Method Summary collapse

Constructor Details

#initialize(name, email) ⇒ Inviter

Returns a new instance of Inviter.



8
9
10
11
# File 'lib/artisan/notifications/inviter.rb', line 8

def initialize(name, email)
  @name = name
  @email = email
end

Instance Method Details

#add_to_future_users(project) ⇒ Object



21
22
23
# File 'lib/artisan/notifications/inviter.rb', line 21

def add_to_future_users(project)
  Artisan::Repository.future_user.create(:email => @email, :project_id => project.id)
end

#inviteObject



13
14
15
16
17
18
19
# File 'lib/artisan/notifications/inviter.rb', line 13

def invite
  if valid_name? && valid_email?
    mail_invite
  else
    raise "Name and email fields are required, please fill out all fields and try again."
  end
end