Class: InvitationForms::CreateBulk

Inherits:
ApplicationForm
  • Object
show all
Defined in:
app/forms/simple_teams/invitation_forms/create_bulk.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(team, current_user) ⇒ CreateBulk

Returns a new instance of CreateBulk.



6
7
8
9
10
# File 'app/forms/simple_teams/invitation_forms/create_bulk.rb', line 6

def initialize(team, current_user)
  @team = team
  @current_user = current_user
  @emails = []
end

Instance Attribute Details

#accessible_emailsObject

Returns the value of attribute accessible_emails.



4
5
6
# File 'app/forms/simple_teams/invitation_forms/create_bulk.rb', line 4

def accessible_emails
  @accessible_emails
end

#current_userObject

Returns the value of attribute current_user.



4
5
6
# File 'app/forms/simple_teams/invitation_forms/create_bulk.rb', line 4

def current_user
  @current_user
end

#emailsObject

Returns the value of attribute emails.



4
5
6
# File 'app/forms/simple_teams/invitation_forms/create_bulk.rb', line 4

def emails
  @emails
end

#roleObject

Returns the value of attribute role.



4
5
6
# File 'app/forms/simple_teams/invitation_forms/create_bulk.rb', line 4

def role
  @role
end

#select2_emailsObject

Returns the value of attribute select2_emails.



4
5
6
# File 'app/forms/simple_teams/invitation_forms/create_bulk.rb', line 4

def select2_emails
  @select2_emails
end

#single_vs_multipleObject

Returns the value of attribute single_vs_multiple.



4
5
6
# File 'app/forms/simple_teams/invitation_forms/create_bulk.rb', line 4

def single_vs_multiple
  @single_vs_multiple
end

#teamObject

Returns the value of attribute team.



4
5
6
# File 'app/forms/simple_teams/invitation_forms/create_bulk.rb', line 4

def team
  @team
end

Instance Method Details

#available_rolesObject

Attributes



29
30
31
# File 'app/forms/simple_teams/invitation_forms/create_bulk.rb', line 29

def available_roles
  SimpleTeams::Membership.roles
end

#perform(params) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/forms/simple_teams/invitation_forms/create_bulk.rb', line 12

def perform(params)
  self.assign_attributes(params)
  if accessible?
    self.emails = accessible_emails.split(",").map(&:strip).uniq.reject(&:empty?)
  else
    self.emails = select2_emails.map(&:strip).uniq.reject(&:empty?)
  end

  if valid?
    create_invitations
    generate_notification
  else
    false
  end
end