Class: Qcourses::MemoryCourseRepository
- Inherits:
-
Object
- Object
- Qcourses::MemoryCourseRepository
- Defined in:
- lib/qcourses/models/course_repository.rb
Instance Method Summary collapse
- #all ⇒ Object
- #create_course(attributes) ⇒ Object
- #find(course_id) ⇒ Object
-
#initialize ⇒ MemoryCourseRepository
constructor
A new instance of MemoryCourseRepository.
Constructor Details
#initialize ⇒ MemoryCourseRepository
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
#all ⇒ Object
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 |