Class: Qcourses::MemoryCourseRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/qcourses/models/course_repository.rb

Instance Method Summary collapse

Constructor Details

#initializeMemoryCourseRepository

Returns a new instance of MemoryCourseRepository.



4
5
6
# File 'lib/qcourses/models/course_repository.rb', line 4

def initialize
  @courses = {}
end

Instance Method Details

#allObject



11
12
13
# File 'lib/qcourses/models/course_repository.rb', line 11

def all()
  @courses.values
end

#create_course(attributes) ⇒ Object



7
8
9
10
# File 'lib/qcourses/models/course_repository.rb', line 7

def create_course(attributes)
  raise "should supply course identification" unless attributes.has_key?(:identification)
  @courses[attributes[:identification]] = Course.new(attributes)
end

#find(course_id) ⇒ Object



14
15
16
# File 'lib/qcourses/models/course_repository.rb', line 14

def find(course_id)
  @courses[course_id]
end