Class: TaskRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/djin/repositories/task_repository.rb

Instance Method Summary collapse

Constructor Details

#initialize(tasks = []) ⇒ TaskRepository

Returns a new instance of TaskRepository.



4
5
6
# File 'lib/djin/repositories/task_repository.rb', line 4

def initialize(tasks = [])
  @tasks = tasks
end

Instance Method Details

#add(*tasks) ⇒ Object



8
9
10
# File 'lib/djin/repositories/task_repository.rb', line 8

def add(*tasks)
  @tasks += tasks
end

#allObject



12
13
14
# File 'lib/djin/repositories/task_repository.rb', line 12

def all
  @tasks
end

#find_by_names(names) ⇒ Object



16
17
18
# File 'lib/djin/repositories/task_repository.rb', line 16

def find_by_names(names)
  @tasks.select { |task| names.include?(task.name) }
end