I'm trying to replicate the functionality of Sinatra. Specifically the DSL-like part where you can define routes in the definition of the class. When I try to run my version of a persons-DSL I get the error, undefined method '<<' for nil:NilClass on line 11.
class Persons
class << self
def reset!
@persons = []
end
def add_person title, name
@persons << {
title: title,
name: name
}
end
end
reset!
end
class MyPersons < Persons
add_person 'Dr.', 'Bob'
add_person 'Mr.', 'Jones'
end