mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Rename find_by_parts and find_by_parts? to find and exists?
This commit is contained in:
@@ -499,7 +499,7 @@ module ActionMailer #:nodoc:
|
||||
# ====
|
||||
# TODO: Revisit this
|
||||
# template_exists = @parts.empty?
|
||||
# template_exists ||= template_root.find_by_parts("#{mailer_name}/#{@template}")
|
||||
# template_exists ||= template_root.find("#{mailer_name}/#{@template}")
|
||||
# @body = render_message(@template, @body) if template_exists
|
||||
|
||||
# Finally, if there are other message parts and a textual body exists,
|
||||
@@ -585,7 +585,7 @@ module ActionMailer #:nodoc:
|
||||
|
||||
if file
|
||||
prefix = mailer_name unless file =~ /\//
|
||||
template = view_paths.find_by_parts(file, {:formats => formats}, prefix)
|
||||
template = view_paths.find(file, {:formats => formats}, prefix)
|
||||
end
|
||||
|
||||
layout = _pick_layout(layout,
|
||||
|
||||
@@ -76,7 +76,7 @@ module AbstractController
|
||||
when nil
|
||||
self.class_eval <<-ruby_eval, __FILE__, __LINE__ + 1
|
||||
def _layout(details)
|
||||
if view_paths.find_by_parts?("#{_implied_layout_name}", details, "layouts")
|
||||
if view_paths.exists?("#{_implied_layout_name}", details, "layouts")
|
||||
"#{_implied_layout_name}"
|
||||
else
|
||||
super
|
||||
@@ -131,7 +131,7 @@ module AbstractController
|
||||
def _find_layout(name, details)
|
||||
# TODO: Make prefix actually part of details in ViewPath#find_by_parts
|
||||
prefix = details.key?(:prefix) ? details.delete(:prefix) : "layouts"
|
||||
view_paths.find_by_parts(name, details, prefix)
|
||||
view_paths.find(name, details, prefix)
|
||||
end
|
||||
|
||||
# Returns the default layout for this controller and a given set of details.
|
||||
|
||||
@@ -111,7 +111,7 @@ module AbstractController
|
||||
def _determine_template(options)
|
||||
name = (options[:_template_name] || action_name).to_s
|
||||
|
||||
options[:_template] ||= view_paths.find_by_parts(
|
||||
options[:_template] ||= view_paths.find(
|
||||
name, { :formats => formats }, options[:_prefix], options[:_partial]
|
||||
)
|
||||
end
|
||||
|
||||
@@ -51,7 +51,7 @@ module ActionController
|
||||
|
||||
def method_for_action(action_name)
|
||||
super || begin
|
||||
if view_paths.find_by_parts?(action_name.to_s, {:formats => formats, :locales => [I18n.locale]}, controller_path)
|
||||
if view_paths.exists?(action_name.to_s, {:formats => formats, :locales => [I18n.locale]}, controller_path)
|
||||
"default_render"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -191,7 +191,7 @@ module ActionController #:nodoc:
|
||||
def memoized_find_layout(layout, formats) #:nodoc:
|
||||
return layout if layout.nil? || layout.respond_to?(:render)
|
||||
prefix = layout.to_s =~ /layouts\// ? nil : "layouts"
|
||||
view_paths.find_by_parts(layout.to_s, {:formats => formats}, prefix)
|
||||
view_paths.find(layout.to_s, {:formats => formats}, prefix)
|
||||
end
|
||||
|
||||
def find_layout(*args)
|
||||
|
||||
@@ -202,7 +202,7 @@ module ActionView #:nodoc:
|
||||
|
||||
delegate :logger, :to => :controller, :allow_nil => true
|
||||
|
||||
delegate :find_by_parts, :to => :view_paths
|
||||
delegate :find, :to => :view_paths
|
||||
|
||||
include Context
|
||||
|
||||
|
||||
@@ -33,12 +33,12 @@ module ActionView #:nodoc:
|
||||
super(*objs.map { |obj| self.class.type_cast(obj) })
|
||||
end
|
||||
|
||||
def find_by_parts(path, details = {}, prefix = nil, partial = false)
|
||||
def find(path, details = {}, prefix = nil, partial = false)
|
||||
# template_path = path.sub(/^\//, '')
|
||||
template_path = path
|
||||
|
||||
each do |load_path|
|
||||
if template = load_path.find_by_parts(template_path, details, prefix, partial)
|
||||
if template = load_path.find(template_path, details, prefix, partial)
|
||||
return template
|
||||
end
|
||||
end
|
||||
@@ -48,11 +48,11 @@ module ActionView #:nodoc:
|
||||
raise ActionView::MissingTemplate.new(self, "#{prefix}/#{path} - #{details.inspect} - partial: #{!!partial}")
|
||||
end
|
||||
|
||||
def find_by_parts?(path, extension = nil, prefix = nil, partial = false)
|
||||
def exists?(path, extension = nil, prefix = nil, partial = false)
|
||||
template_path = path.sub(/^\//, '')
|
||||
|
||||
each do |load_path|
|
||||
return true if template = load_path.find_by_parts(template_path, extension, prefix, partial)
|
||||
return true if template = load_path.find(template_path, extension, prefix, partial)
|
||||
end
|
||||
false
|
||||
end
|
||||
@@ -62,7 +62,7 @@ module ActionView #:nodoc:
|
||||
template_path = original_template_path.sub(/^\//, '')
|
||||
|
||||
each do |load_path|
|
||||
if template = load_path.find_by_parts(template_path, format)
|
||||
if template = load_path.find(template_path, format)
|
||||
return template
|
||||
# Try to find html version if the format is javascript
|
||||
elsif format == :js && html_fallback && template = load_path["#{template_path}.#{I18n.locale}.html"]
|
||||
|
||||
@@ -258,7 +258,7 @@ module ActionView
|
||||
|
||||
def _pick_partial_template(partial_path) #:nodoc:
|
||||
prefix = controller_path unless partial_path.include?(?/)
|
||||
find_by_parts(partial_path, {:formats => formats}, prefix, true)
|
||||
find(partial_path, {:formats => formats}, prefix, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,10 +24,10 @@ module ActionView
|
||||
return _render_content(_render_partial(options), layout, options[:locals])
|
||||
end
|
||||
|
||||
layout = find_by_parts(layout, {:formats => formats}) if layout
|
||||
layout = find(layout, {:formats => formats}) if layout
|
||||
|
||||
if file = options[:file]
|
||||
template = find_by_parts(file, {:formats => formats})
|
||||
template = find(file, {:formats => formats})
|
||||
_render_template(template, layout, :locals => options[:locals] || {})
|
||||
elsif inline = options[:inline]
|
||||
_render_inline(inline, layout, options)
|
||||
|
||||
@@ -10,7 +10,7 @@ module ActionView
|
||||
end
|
||||
|
||||
# Normalizes the arguments and passes it on to find_template
|
||||
def find_by_parts(*args)
|
||||
def find(*args)
|
||||
find_all_by_parts(*args).first
|
||||
end
|
||||
|
||||
|
||||
@@ -139,10 +139,10 @@ module AbstractController
|
||||
private
|
||||
def self.layout(formats)
|
||||
begin
|
||||
view_paths.find_by_parts(name.underscore, {:formats => formats}, "layouts")
|
||||
view_paths.find(name.underscore, {:formats => formats}, "layouts")
|
||||
rescue ActionView::MissingTemplate
|
||||
begin
|
||||
view_paths.find_by_parts("application", {:formats => formats}, "layouts")
|
||||
view_paths.find("application", {:formats => formats}, "layouts")
|
||||
rescue ActionView::MissingTemplate
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ module AbstractController
|
||||
module Testing
|
||||
|
||||
class ControllerWithHelpers < AbstractController::Base
|
||||
include RenderingController
|
||||
include AbstractController::RenderingController
|
||||
include Helpers
|
||||
|
||||
def render(string)
|
||||
|
||||
Reference in New Issue
Block a user