While wrapping up the second week of Hacker School and finishing Constantin’s “Sinatra: Up and Running”, I decided to peer under the hood of Sinatra itself and investigate how the magic unfolded. I was quite pleased when I ran into one of my favourite Ruby black-magic methods: define_method.
Prima facie, it may rather deceptively appear that Sinatra’s basic HTTP route definitions (get ‘/’, post ‘/’, put ‘/’, delete ‘/’) are method definitions, but au contraire- they are method calls deep inside the Sinatra lair. Let’s take a peek.