This is a more focused version of a previous question about my work around Sinatra route processing methods.
From my understanding of the source code, Sinatra takes a method block in the route and passes a new method containing the same ie body:
get "some/url" do return "Hello World" # this gets taken out end
So, in this example, the body of the method seems to be copied to a new method that applies to the Sinatra object. I'm just wondering why this is happening, I tried to switch to my IRC channel, but no one was there and the mailing list is not so busy.
The main part of the source code that I am talking about within them is within base.rb around line 1180:
def generate_method(method_name, &block) define_method(method_name, &block) method = instance_method method_name remove_method method_name method end
So is there any specific reason why they do this, and not just a link to this method?
The reason I'm asking this question is because since Sinatra is currently dealing with this, it makes it impossible to have a method that has knowledge outside of itself and breaks up encapsulation of classes just by using one method without context.
source share