Class: Artisan::Stories::StoriesInteractor
- Inherits:
-
Object
- Object
- Artisan::Stories::StoriesInteractor
- Defined in:
- lib/artisan/stories/stories_interactor.rb
Instance Method Summary collapse
- #backlog(filter_tag = nil) ⇒ Object
- #completed ⇒ Object
- #create(story_attributes, callbacks) ⇒ Object
- #delete(number) ⇒ Object
- #find(number) ⇒ Object
- #find_by_iteration(iteration_number) ⇒ Object
-
#initialize(project_id, user = nil) ⇒ StoriesInteractor
constructor
A new instance of StoriesInteractor.
- #update(number, story_attributes, callbacks) ⇒ Object
Constructor Details
#initialize(project_id, user = nil) ⇒ StoriesInteractor
Returns a new instance of StoriesInteractor.
14 15 16 17 |
# File 'lib/artisan/stories/stories_interactor.rb', line 14 def initialize(project_id, user = nil) @project = project_repository.find(project_id) @user = user end |
Instance Method Details
#backlog(filter_tag = nil) ⇒ Object
41 42 43 44 |
# File 'lib/artisan/stories/stories_interactor.rb', line 41 def backlog(filter_tag = nil) backlog_stories = filtered(filter_tag, @project.stories.backlog) return StoryCollection.new(backlog_stories) end |
#completed ⇒ Object
46 47 48 |
# File 'lib/artisan/stories/stories_interactor.rb', line 46 def completed @project.stories.complete end |
#create(story_attributes, callbacks) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/artisan/stories/stories_interactor.rb', line 19 def create(story_attributes, callbacks) model = repository.create_for_project(@project, story_attributes) set_story_number_for model story = CrudStrategy.create(model, callbacks, repository) Activity::StoryAuditor.created(story.id, @project.id, @user.id, story_attributes) return story end |
#delete(number) ⇒ Object
35 36 37 38 39 |
# File 'lib/artisan/stories/stories_interactor.rb', line 35 def delete(number) story = find(number) repository.delete(story) Activity::StoryAuditor.deleted(story.id, @project.id, @user.id) end |
#find(number) ⇒ Object
55 56 57 |
# File 'lib/artisan/stories/stories_interactor.rb', line 55 def find(number) repository.find(number, @project) end |
#find_by_iteration(iteration_number) ⇒ Object
50 51 52 53 |
# File 'lib/artisan/stories/stories_interactor.rb', line 50 def find_by_iteration(iteration_number) iteration = @project.iterations.find_by_number iteration_number iteration.stories(:include => 'assigned_user') end |
#update(number, story_attributes, callbacks) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/artisan/stories/stories_interactor.rb', line 27 def update(number, story_attributes, callbacks) story = find(number) original_attributes = story.attributes story = CrudStrategy.update(story, story_attributes, @user, callbacks) Activity::StoryAuditor.updated(story.id, @project.id, @user.id, original_attributes, story_attributes) end |