Class: Artisan::Iterations::IterationWorkflowInteractor

Inherits:
Object
  • Object
show all
Defined in:
lib/artisan/iterations/iteration_workflow_interactor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(iteration_id, user, iteration_repository = Repository.iteration) ⇒ IterationWorkflowInteractor

Returns a new instance of IterationWorkflowInteractor.



15
16
17
18
19
# File 'lib/artisan/iterations/iteration_workflow_interactor.rb', line 15

def initialize(iteration_id, user, iteration_repository = Repository.iteration)
  self.iteration = iteration_repository.find(iteration_id)
  self.project = iteration.project
  self.user = user
end

Instance Attribute Details

#iterationObject

Returns the value of attribute iteration.



13
14
15
# File 'lib/artisan/iterations/iteration_workflow_interactor.rb', line 13

def iteration
  @iteration
end

#projectObject

Returns the value of attribute project.



13
14
15
# File 'lib/artisan/iterations/iteration_workflow_interactor.rb', line 13

def project
  @project
end

#userObject

Returns the value of attribute user.



13
14
15
# File 'lib/artisan/iterations/iteration_workflow_interactor.rb', line 13

def user
  @user
end

Instance Method Details

#completeObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/artisan/iterations/iteration_workflow_interactor.rb', line 21

def complete
  iteration.update_attributes!(:committed_points_at_completion => total_points)
  iteration.update_attributes!(:complete => true, :completed_at => Time.now)

  Activity::IterationAuditor.completed(iteration.id, iteration.project.id, user.id)
  MoveToBacklog.new(iteration).move
#
#         Artisan::Stories.for(project.id, user).backlog.each do |story|
#           story.position += 1 if story.position
#           Artisan::Repository.story.save(story)
#         end

  return IterationWorkflowPresenter.new(iteration.id, iteration.project.id)
end

#resumeObject



36
37
38
39
40
41
# File 'lib/artisan/iterations/iteration_workflow_interactor.rb', line 36

def resume
  iteration.update_attributes!(:committed_points_at_completion => nil)
  iteration.update_attributes!(:complete => false, :completed_at => nil)
  Activity::IterationAuditor.resumed(iteration.id, iteration.project.id, user.id)
  return IterationWorkflowPresenter.new(iteration.id, iteration.project.id)
end

#startObject



43
44
45
46
47
# File 'lib/artisan/iterations/iteration_workflow_interactor.rb', line 43

def start
  iteration.update_attributes!(:committed_points => total_points)
  Activity::IterationAuditor.started(iteration.id, iteration.project.id, user.id)
  return IterationWorkflowPresenter.new(iteration.id, iteration.project.id)
end

#stateObject



49
50
51
52
53
# File 'lib/artisan/iterations/iteration_workflow_interactor.rb', line 49

def state
  return :completed if iteration.complete?
  return :working if !iteration.committed_points.nil?
  return :planning
end