Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Use block.source_location to get the correct method name for a condition... #588

Closed
wants to merge 1 commit into from

2 participants

@markburns

... even when in debugger

Whilst delving around in sinatra internals I noticed that the values stored in the @routes instance variable were a little impenetrable because of the way that caller.first was giving a method name of

"`send' condition"

whilst in the debugger.

It might not be the responsibility of sinatra to care about people using the debugger, so I can understand if this doesn't belong here, so more of a speculative pull request.

Also I've not looked into the tests or how this might be tested, so happy to address that if you're interested in merging this in.

@rkh
Owner

Proc#source_location is 1.9 only.

@markburns

Ah I see. Thanks. I'll close this.

@markburns markburns closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 30, 2012
  1. @markburns
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/sinatra/base.rb
View
4 lib/sinatra/base.rb
@@ -1201,7 +1201,9 @@ def add_filter(type, path = nil, options = {}, &block)
# Add a route condition. The route is considered non-matching when the
# block returns false.
- def condition(name = "#{caller.first[/`.*'/]} condition", &block)
+ def condition(name = nil, &block)
+ name ||= "#{caller.detect{|s| s[block.source_location]}[/`.*'/]} condition"
+
@conditions << generate_method(name, &block)
end
Something went wrong with that request. Please try again.