Class: ArtisanMemoryRepository::StoryRepository
- Inherits:
-
Object
- Object
- ArtisanMemoryRepository::StoryRepository
show all
- Includes:
- BaseRepository
- Defined in:
- lib/artisan-memory-repository/story_repository.rb
Instance Method Summary
collapse
#create, #destroy_all, #find_each, #records, #save, #where
Instance Method Details
#add_to_iteration(iteration, story) ⇒ Object
45
46
47
48
49
50
|
# File 'lib/artisan-memory-repository/story_repository.rb', line 45
def add_to_iteration(iteration, story)
iteration.stories.delete_if { |s| s.id == story.id }
iteration.stories << story
story.iteration = iteration
Artisan::Repository.iteration.save(iteration)
end
|
#all(iteration) ⇒ Object
64
65
66
|
# File 'lib/artisan-memory-repository/story_repository.rb', line 64
def all(iteration)
iteration.stories
end
|
#backlog(project) ⇒ Object
81
82
83
|
# File 'lib/artisan-memory-repository/story_repository.rb', line 81
def backlog(project)
records.values.select { |r| r.iteration.nil? }
end
|
#by_project(project) ⇒ Object
33
34
35
|
# File 'lib/artisan-memory-repository/story_repository.rb', line 33
def by_project(project)
records.values.select{|r| r.project.nil? ? false : r.project.id == project.id }
end
|
#completed(iteration) ⇒ Object
77
78
79
|
# File 'lib/artisan-memory-repository/story_repository.rb', line 77
def completed(iteration)
iteration.stories.select(&:complete)
end
|
#create!(attributes = {}) ⇒ Object
25
26
27
|
# File 'lib/artisan-memory-repository/story_repository.rb', line 25
def create!(attributes = {})
save model_class.new(attributes)
end
|
#create_for_project(project, attrs = {}) ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/artisan-memory-repository/story_repository.rb', line 37
def create_for_project(project, attrs = {})
story = create(attrs)
project.stories << story
story.project = project
Artisan::Repository.project.save(project)
story
end
|
#delete(story) ⇒ Object
58
59
60
61
62
|
# File 'lib/artisan-memory-repository/story_repository.rb', line 58
def delete(story)
deleted = records.delete(story.id)
deleted.deleted = true
deleted
end
|
#find(number, project) ⇒ Object
16
17
18
19
20
21
22
23
|
# File 'lib/artisan-memory-repository/story_repository.rb', line 16
def find(number, project)
result = records.values.find do |record|
record.project == project && record.number == number
end
raise Artisan::RecordNotFound.new if result.nil?
return result
end
|
#for_user(user) ⇒ Object
29
30
31
|
# File 'lib/artisan-memory-repository/story_repository.rb', line 29
def for_user(user)
records.values.select{|r| r.assigned_user == user}
end
|
#new(attributes = {}) ⇒ Object
12
13
14
|
# File 'lib/artisan-memory-repository/story_repository.rb', line 12
def new(attributes = {})
model_class.new(attributes)
end
|
#ready(iteration) ⇒ Object
68
69
70
|
# File 'lib/artisan-memory-repository/story_repository.rb', line 68
def ready(iteration)
iteration.stories.select{|r| r.assigned_user.nil? && !r.complete}
end
|
#remove_from_iteration(story) ⇒ Object
52
53
54
55
56
|
# File 'lib/artisan-memory-repository/story_repository.rb', line 52
def remove_from_iteration(story)
iteration = story.iteration
story.iteration = nil
iteration.stories.delete_if { |s| s.id == story.id }
end
|
#working(iteration) ⇒ Object
72
73
74
75
|
# File 'lib/artisan-memory-repository/story_repository.rb', line 72
def working(iteration)
iteration.stories.select{|r| !r.assigned_user.nil? &&
!r.complete}
end
|