diff options
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/abstract_controller/callbacks.rb | 10 | ||||
-rw-r--r-- | actionpack/lib/action_controller/metal/session_management.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/http/mime_type.rb | 7 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/callbacks.rb | 8 | ||||
-rw-r--r-- | actionpack/lib/action_view/base.rb | 18 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/record_tag_helper.rb | 6 | ||||
-rw-r--r-- | actionpack/lib/action_view/paths.rb | 7 | ||||
-rw-r--r-- | actionpack/lib/action_view/render/partials.rb | 5 | ||||
-rw-r--r-- | actionpack/lib/action_view/render/rendering.rb | 22 |
9 files changed, 49 insertions, 36 deletions
diff --git a/actionpack/lib/abstract_controller/callbacks.rb b/actionpack/lib/abstract_controller/callbacks.rb index 379eaf6d8e..ee496dadc5 100644 --- a/actionpack/lib/abstract_controller/callbacks.rb +++ b/actionpack/lib/abstract_controller/callbacks.rb @@ -1,13 +1,11 @@ -require "active_support/new_callbacks" - module AbstractController module Callbacks extend ActiveSupport::Concern - # Uses ActiveSupport::NewCallbacks as the base functionality. For + # Uses ActiveSupport::Callbacks as the base functionality. For # more details on the whole callback system, read the documentation - # for ActiveSupport::NewCallbacks. - include ActiveSupport::NewCallbacks + # for ActiveSupport::Callbacks. + include ActiveSupport::Callbacks included do define_callbacks :process_action, :terminator => "response_body" @@ -16,7 +14,7 @@ module AbstractController # Override AbstractController::Base's process_action to run the # process_action callbacks around the normal behavior. def process_action(method_name) - _run_process_action_callbacks(method_name) do + run_callbacks(:process_action, method_name) do super end end diff --git a/actionpack/lib/action_controller/metal/session_management.rb b/actionpack/lib/action_controller/metal/session_management.rb index ffce8e1bd1..654aa08cd3 100644 --- a/actionpack/lib/action_controller/metal/session_management.rb +++ b/actionpack/lib/action_controller/metal/session_management.rb @@ -16,7 +16,7 @@ module ActionController #:nodoc: self.session_store = ActiveRecord::SessionStore else @@session_store = store.is_a?(Symbol) ? - Session.const_get(store.to_s.camelize) : + ActionDispatch::Session.const_get(store.to_s.camelize) : store end end diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb index cc989d6625..e85823d8db 100644 --- a/actionpack/lib/action_dispatch/http/mime_type.rb +++ b/actionpack/lib/action_dispatch/http/mime_type.rb @@ -10,7 +10,12 @@ module Mime %w(<< concat shift unshift push pop []= clear compact! collect! delete delete_at delete_if flatten! map! insert reject! reverse! replace slice! sort! uniq!).each do |method| - define_method(method) {|*args| @symbols = nil; super(*args) } + module_eval <<-CODE + def #{method}(*args) + @symbols = nil + super + end + CODE end end diff --git a/actionpack/lib/action_dispatch/middleware/callbacks.rb b/actionpack/lib/action_dispatch/middleware/callbacks.rb index 56d6da1706..49bc20f11f 100644 --- a/actionpack/lib/action_dispatch/middleware/callbacks.rb +++ b/actionpack/lib/action_dispatch/middleware/callbacks.rb @@ -1,6 +1,6 @@ module ActionDispatch class Callbacks - include ActiveSupport::NewCallbacks + include ActiveSupport::Callbacks define_callbacks :call, :terminator => "result == false", :rescuable => true define_callbacks :prepare, :scope => :name @@ -37,12 +37,12 @@ module ActionDispatch def initialize(app, prepare_each_request = false) @app, @prepare_each_request = app, prepare_each_request - _run_prepare_callbacks + run_callbacks(:prepare) end def call(env) - _run_call_callbacks do - _run_prepare_callbacks if @prepare_each_request + run_callbacks(:call) do + run_callbacks(:prepare) if @prepare_each_request @app.call(env) end end diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 82b419d846..31e9c5ef9d 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -236,15 +236,15 @@ module ActionView #:nodoc: # they are in AC. if controller.class.respond_to?(:_helper_serial) klass = @views[controller.class._helper_serial] ||= Class.new(self) do - name = controller.class.name.gsub(/::/, '__') - - Subclasses.class_eval do - if method(:const_defined?).arity == 1 - remove_const(name) if const_defined?(name) # Ruby 1.8.x - else - remove_const(name) if const_defined?(name, false) # Ruby 1.9.x - end - const_set(name, self) + const_set(:CONTROLLER_CLASS, controller.class) + + # Try to make stack traces clearer + def self.name + "ActionView for #{CONTROLLER_CLASS}" + end + + def inspect + "#<#{self.class.name}>" end if controller.respond_to?(:_helpers) diff --git a/actionpack/lib/action_view/helpers/record_tag_helper.rb b/actionpack/lib/action_view/helpers/record_tag_helper.rb index 0cdb70e217..31411dc08a 100644 --- a/actionpack/lib/action_view/helpers/record_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/record_tag_helper.rb @@ -15,7 +15,7 @@ module ActionView def div_for(record, *args, &block) content_tag_for(:div, record, *args, &block) end - + # content_tag_for creates an HTML element with id and class parameters # that relate to the specified Active Record object. For example: # @@ -34,7 +34,7 @@ module ActionView # <% content_tag_for(:tr, @person, :foo) do %> ... # # produces: - # + # # <tr id="foo_person_123" class="person">... # # content_tag_for also accepts a hash of options, which will be converted to @@ -50,7 +50,7 @@ module ActionView def content_tag_for(tag_name, record, *args, &block) prefix = args.first.is_a?(Hash) ? nil : args.shift options = args.extract_options! - options.merge!({ :class => "#{dom_class(record)} #{options[:class]}".strip, :id => dom_id(record, prefix) }) + options.merge!({ :class => "#{dom_class(record, prefix)} #{options[:class]}".strip, :id => dom_id(record, prefix) }) content_tag(tag_name, options, &block) end end diff --git a/actionpack/lib/action_view/paths.rb b/actionpack/lib/action_view/paths.rb index 5524a3219a..23bde61f9c 100644 --- a/actionpack/lib/action_view/paths.rb +++ b/actionpack/lib/action_view/paths.rb @@ -1,8 +1,11 @@ module ActionView #:nodoc: class PathSet < Array #:nodoc: - def self.type_cast(obj) + def self.type_cast(obj, cache = nil) + # TODO: Clean this up if obj.is_a?(String) - cache = !defined?(Rails) || !Rails.respond_to?(:configuration) || Rails.configuration.cache_classes + if cache.nil? + cache = !defined?(Rails) || Rails.application.config.cache_classes + end FileSystemResolverWithFallback.new(obj, :cache => cache) else obj diff --git a/actionpack/lib/action_view/render/partials.rb b/actionpack/lib/action_view/render/partials.rb index 4f60566a09..2eb88ae3e5 100644 --- a/actionpack/lib/action_view/render/partials.rb +++ b/actionpack/lib/action_view/render/partials.rb @@ -296,7 +296,10 @@ module ActionView end def _find_template(path) - prefix = @view.controller.controller_path unless path.include?(?/) + if controller = @view.controller + prefix = controller.controller_path unless path.include?(?/) + end + @view.find(path, {:formats => @view.formats}, prefix, true) end diff --git a/actionpack/lib/action_view/render/rendering.rb b/actionpack/lib/action_view/render/rendering.rb index 0cab035ede..b6f5b9b6d1 100644 --- a/actionpack/lib/action_view/render/rendering.rb +++ b/actionpack/lib/action_view/render/rendering.rb @@ -14,6 +14,7 @@ module ActionView case options when Hash layout = options[:layout] + options[:locals] ||= {} if block_given? return concat(_render_partial(options.merge(:partial => layout), &block)) @@ -25,11 +26,11 @@ module ActionView if file = options[:file] template = find(file, {:formats => formats}) - _render_template(template, layout, :locals => options[:locals] || {}) + _render_template(template, layout, :locals => options[:locals]) elsif inline = options[:inline] _render_inline(inline, layout, options) elsif text = options[:text] - _render_text(text, layout, options) + _render_text(text, layout, options[:locals]) end when :update update_page(&block) @@ -80,16 +81,19 @@ module ActionView def _render_inline(inline, layout, options) handler = Template.handler_class_for_extension(options[:type] || "erb") - template = Template.new(options[:inline], "inline #{options[:inline].inspect}", handler, {}) - locals = options[:locals] || {} + template = Template.new(options[:inline], + "inline #{options[:inline].inspect}", handler, {}) + + locals = options[:locals] content = template.render(self, locals) - content = layout.render(self, locals) {|*name| _layout_for(*name) { content } } if layout - content + _render_text(content, layout, locals) end - def _render_text(text, layout, options) - text = layout.render(self, options[:locals]) { text } if layout - text + def _render_text(content, layout, locals) + content = layout.render(self, locals) do |*name| + _layout_for(*name) { content } + end if layout + content end # This is the API to render a ViewContext's template from a controller. |