Class: SimpleTeams::LeaveTeamService
- Inherits:
-
Object
- Object
- SimpleTeams::LeaveTeamService
- Includes:
- ActiveModel::Model
- Defined in:
- app/service_objects/simple_teams/leave_team_service.rb
Instance Attribute Summary collapse
-
#team_id ⇒ Object
Returns the value of attribute team_id.
-
#user_id ⇒ Object
Returns the value of attribute user_id.
Instance Method Summary collapse
-
#initialize(user_id, team_id) ⇒ LeaveTeamService
constructor
A new instance of LeaveTeamService.
- #membership ⇒ Object
- #perform ⇒ Object
- #team ⇒ Object
- #user ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(user_id, team_id) ⇒ LeaveTeamService
Returns a new instance of LeaveTeamService.
7 8 9 10 |
# File 'app/service_objects/simple_teams/leave_team_service.rb', line 7 def initialize(user_id, team_id) @user_id = user_id @team_id = team_id end |
Instance Attribute Details
#team_id ⇒ Object
Returns the value of attribute team_id.
5 6 7 |
# File 'app/service_objects/simple_teams/leave_team_service.rb', line 5 def team_id @team_id end |
#user_id ⇒ Object
Returns the value of attribute user_id.
5 6 7 |
# File 'app/service_objects/simple_teams/leave_team_service.rb', line 5 def user_id @user_id end |
Instance Method Details
#membership ⇒ Object
31 32 33 |
# File 'app/service_objects/simple_teams/leave_team_service.rb', line 31 def membership @membership ||= user.membership_for_team(team) end |
#perform ⇒ Object
18 19 20 21 |
# File 'app/service_objects/simple_teams/leave_team_service.rb', line 18 def perform membership.destroy generate_notification end |
#team ⇒ Object
27 28 29 |
# File 'app/service_objects/simple_teams/leave_team_service.rb', line 27 def team @team ||= SimpleTeams::Team.find(team_id) end |
#user ⇒ Object
23 24 25 |
# File 'app/service_objects/simple_teams/leave_team_service.rb', line 23 def user @user ||= SimpleTeams.member_class.find(user_id) end |
#valid? ⇒ Boolean
12 13 14 15 16 |
# File 'app/service_objects/simple_teams/leave_team_service.rb', line 12 def valid? self.errors.clear validate_not_last_owner !self.errors.any? end |