| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
| |
we know that this call only wants the path returned, so lets call a
method that returns the path.
|
|
|
|
| |
this allows us to avoid nil checks on the return value
|
|
|
|
| |
hash lookup should be faster than searching an array.
|
|
|
|
|
| |
every call to default_resources_path_names allocates a new hash, no need
to dup
|
|
|
|
| |
we can `super` in to the previous implementation.
|
|
|
|
|
| |
we already know what helpers are path helpers, so just iterate through
that list and define the helpers with warnings
|
| |
|
|
|
|
|
| |
this lets us avoid hard coding a regexp for separating path and url
helpers in the clear! method.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Email does not support relative links since there is no implicit host. Therefore all links inside of emails must be fully qualified URLs. All path helpers are now deprecated. When removed, the error will give early indication to developers to use `*_url` methods instead.
Currently if a developer uses a `*_path` helper, their tests and `mail_view` will not catch the mistake. The only way to see the error is by sending emails in production. Preventing sending out emails with non-working path's is the desired end goal of this PR.
Currently path helpers are mixed-in to controllers (the ActionMailer::Base acts as a controller). All `*_url` and `*_path` helpers are made available through the same module. This PR separates this behavior into two modules so we can extend the `*_path` methods to add a Deprecation to them. Once deprecated we can use this same area to raise a NoMethodError and add an informative message directing the developer to use `*_url` instead.
The module with warnings is only mixed in when a controller returns false from the newly added `supports_relative_path?`.
Paired @sgrif & @schneems
|
|
|
|
| |
use helpers.include? so we don't get any false positives
|
|
|
|
|
| |
we should not be accessing internals to figure out if a method is
defined.
|
|
|
|
|
| |
since helpers is a set, we can be confident about when to remove methods
from the module.
|
|
|
|
| |
after this, we can disconnect @module from the instance
|
|
|
|
| |
we can cache the module on the stack, then reuse it
|
| |
|
|
|
|
|
| |
we know the routes should not be "optimized" when mounting an
application
|
|
|
|
|
| |
this allows us to avoid 2 hash allocations per named helper definition,
also we can avoid a `merge` and `delete`.
|
|
|
|
|
|
| |
since we know that the route should be a path or fully qualified, we can
pass a strategy object that handles generation. This allows us to
eliminate an "if only_path" branch when generating urls.
|
| |
|
|
|
|
|
| |
If we extract the options from the user facing method call ASAP, then we
can simplify internal logic.
|
|
|
|
| |
Now we can override how requests are dispatched in the routeset object
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
Unwrap Constraints objects. I don't actually think it's possible
to pass a Constraints object to this constructor, but there were
multiple places that kept testing children of this object. I
*think* they were just being defensive, but I have no idea.
|
|
|
|
|
|
| |
this also changes the constructor. We don't need to pass more options
than "defaults" (whatever defaults are, ugh. probably another hash of
stupid stuff).
|
| |
|
| |
|
| |
|
|
|
|
| |
this decouples our code from the env hash a bit.
|
| |
|
| |
|
| |
|
|
|
|
|
| |
The optimized and non-optimized path share more code now without
significant performance degretation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Example:
x = [1,2,3,4]
y = [3,2,1]
def test x, y
hash = {}
x.zip(y) { |k,v| hash[k] = v }
hash
end
def test2 x, y
Hash[x.zip(y)]
end
def test3 x, y
x.zip(y).each_with_object({}) { |(k,v),hash| hash[k] = v }
end
def stat num
start = GC.stat(:total_allocated_object)
num.times { yield }
total_obj_count = GC.stat(:total_allocated_object) - start
puts "#{total_obj_count / num} allocations per call"
end
stat(100) { test(x,y) }
stat(100) { test2(x,y) }
stat(100) { test3(x,y) }
__END__
2 allocations per call
7 allocations per call
8 allocations per call
|
| |
|
| |
|
| |
|
|
|
|
|
| |
The bit of URL generation that is optimized is the generation of
the path so things like :host, :port, etc. are irrelevant.
|
| |
|
|
|
|
| |
Then we can avoid nil checks
|
| |
|