Class: Artisan::Projects::ProjectsInteractor

Inherits:
Object
  • Object
show all
Defined in:
lib/artisan/projects/projects_interactor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ ProjectsInteractor

Returns a new instance of ProjectsInteractor.



14
15
16
# File 'lib/artisan/projects/projects_interactor.rb', line 14

def initialize(user)
  @user = user
end

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user.



12
13
14
# File 'lib/artisan/projects/projects_interactor.rb', line 12

def user
  @user
end

Instance Method Details

#completed_stories(project_id) ⇒ Object



40
41
42
43
44
# File 'lib/artisan/projects/projects_interactor.rb', line 40

def completed_stories(project_id)
  project = find(project_id)
  completed_stories = Stories::StoriesInteractor.new(project).completed
  return CompletedStoriesPresenter.new(completed_stories)
end

#create(project_attributes, callbacks) ⇒ Object



24
25
26
# File 'lib/artisan/projects/projects_interactor.rb', line 24

def create(project_attributes, callbacks)
  ProjectCreator.new(user, callbacks).create(project_attributes)
end

#find(project_id) ⇒ Object



18
19
20
21
22
# File 'lib/artisan/projects/projects_interactor.rb', line 18

def find(project_id)
  project = repository.find(project_id)
  check_permissions(project, user)
  return project
end

#newObject



28
29
30
# File 'lib/artisan/projects/projects_interactor.rb', line 28

def new
  repository.new
end

#update(id, project_attributes, callbacks) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/artisan/projects/projects_interactor.rb', line 32

def update(id, project_attributes, callbacks)
  project = find(id)
  original_attributes = project.attributes
  project = CrudStrategy.update(project, project_attributes, user, callbacks)
  Activity::ProjectAuditor.updated(project.id, user.id, original_attributes, project_attributes)
  return project
end