Class: ArtisanMemoryRepository::IterationRepository

Inherits:
Object
  • Object
show all
Includes:
BaseRepository
Defined in:
lib/artisan-memory-repository/iteration_repository.rb

Instance Method Summary collapse

Methods included from BaseRepository

#create, #delete, #destroy_all, #find, #find_each, #records, #save, #where

Instance Method Details

#by_project(project, options = {}) ⇒ Object



27
28
29
# File 'lib/artisan-memory-repository/iteration_repository.rb', line 27

def by_project(project, options = {})
  records.values.find_all {|r| r.project == project}.sort_by(&:number).reverse
end

#by_project_by_finish_date(project) ⇒ Object



31
32
33
# File 'lib/artisan-memory-repository/iteration_repository.rb', line 31

def by_project_by_finish_date(project)
  self.by_project(project).sort_by!{ |iteration| Date.parse(iteration.finish_date) }.reverse
end

#create_for_project(project, attrs) ⇒ Object



16
17
18
19
20
21
# File 'lib/artisan-memory-repository/iteration_repository.rb', line 16

def create_for_project(project, attrs)
  iteration = model_class.new(attrs)
  iteration.project = project
  project.iterations << iteration
  save(iteration)
end

#find_by_number(project, number) ⇒ Object



23
24
25
# File 'lib/artisan-memory-repository/iteration_repository.rb', line 23

def find_by_number(project, number)
  records.values.find {|r| r.project == project && r.number = number}
end

#model_classObject



8
9
10
# File 'lib/artisan-memory-repository/iteration_repository.rb', line 8

def model_class
  ArtisanMemoryRepository::Iteration
end

#new(attributes = {}) ⇒ Object



12
13
14
# File 'lib/artisan-memory-repository/iteration_repository.rb', line 12

def new(attributes = {})
  model_class.new(attributes)
end