Class: SimpleTeams::InitializeTeamService
- Inherits:
-
Object
- Object
- SimpleTeams::InitializeTeamService
- Defined in:
- app/service_objects/simple_teams/initialize_team_service.rb
Instance Attribute Summary collapse
-
#team ⇒ Object
Returns the value of attribute team.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(user, team) ⇒ InitializeTeamService
constructor
A new instance of InitializeTeamService.
- #perform ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(user, team) ⇒ InitializeTeamService
Returns a new instance of InitializeTeamService.
6 7 8 9 |
# File 'app/service_objects/simple_teams/initialize_team_service.rb', line 6 def initialize(user, team) @user = user @team = team end |
Instance Attribute Details
#team ⇒ Object
Returns the value of attribute team.
4 5 6 |
# File 'app/service_objects/simple_teams/initialize_team_service.rb', line 4 def team @team end |
#user ⇒ Object
Returns the value of attribute user.
4 5 6 |
# File 'app/service_objects/simple_teams/initialize_team_service.rb', line 4 def user @user end |
Instance Method Details
#perform ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'app/service_objects/simple_teams/initialize_team_service.rb', line 15 def perform ActiveRecord::Base.transaction do team.memberships.create( :member => user, :role => :owner ) end end |
#valid? ⇒ Boolean
11 12 13 |
# File 'app/service_objects/simple_teams/initialize_team_service.rb', line 11 def valid? !user.teams.include? team end |