lib/models/assignment.rb in bobross-0.1.6 vs lib/models/assignment.rb in bobross-0.1.7
- old
+ new
@@ -1,24 +1,27 @@
class Assignment < Forgery
attr_reader :name, :description, :due_at, :lock_at, :course_id, :assignment_group
attr_writer :due_at, :lock_at
- def initialize(name, description, due_at, lock_at, course, group)
- @name = name
- @description = description
- @due_at = due_at
- @lock_at = lock_at
- @course_id = course_id
- @assignment_group = assignment_group
+ def initialize(opts = {})
+ @name = opts[:name] if opts[:name]
+ @description = opts[:description] if opts[:description]
+ @due_at = opts[:due_at] if opts[:due_at]
+ @lock_at = opts[:lock_at] if opts[:lock_at]
+ @course_id = opts[:course_id] if opts[:course_id]
+ @assignment_group = opts[:assignment_group] if opts[:assignment_group]
end
def self.random (course = 1, group = 1)
d = Forgery('date').date
Assignment.new(
- "What #{Forgery('name').job_title} #{Forgery('name').full_name} said about #{Forgery('name').industry}",
- "#{Forgery('lorem_ipsum').paragraphs}",
- d,
- d+10.days,
- course,
- group )
+ {
+ name: "What #{Forgery('name').job_title} #{Forgery('name').full_name} said about #{Forgery('name').industry}",
+ description: "#{Forgery('lorem_ipsum').paragraphs}",
+ due_at: d,
+ lock_at: d+10.days,
+ course_id: course,
+ assignment_group: group
+ }
+ )
end
end