Class: SimpleTeams::InvitationForm

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(team, current_user) ⇒ InvitationForm

Returns a new instance of InvitationForm.

Raises:

  • (NotImplementedError)


6
7
8
# File 'app/forms/simple_teams/invitation_form.rb', line 6

def initialize(team, current_user)
  raise NotImplementedError
end

Instance Attribute Details

#current_userObject

Returns the value of attribute current_user.



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

def current_user
  @current_user
end

#emailObject

Returns the value of attribute email.



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

def email
  @email
end

#invitationObject

Returns the value of attribute invitation.



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

def invitation
  @invitation
end

#roleObject

Returns the value of attribute role.



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

def role
  @role
end

#teamObject

Returns the value of attribute team.



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

def team
  @team
end

Class Method Details

.invitation_attributesObject

Attributes



22
23
24
# File 'app/forms/simple_teams/invitation_form.rb', line 22

def self.invitation_attributes
  [:email, :role]
end

Instance Method Details

#available_rolesObject



26
27
28
# File 'app/forms/simple_teams/invitation_form.rb', line 26

def available_roles
  @available_roles ||= SimpleTeams::Membership.roles
end

#perform(params) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'app/forms/simple_teams/invitation_form.rb', line 10

def perform(params)
  self.assign_attributes(params)

  if valid?
    invitation.update!(params)
    generate_notification
  else
    false
  end
end