aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-12-08 15:23:23 +0100
committerJosé Valim <jose.valim@gmail.com>2011-12-08 16:39:06 +0100
commitefc28a7f701e518eb747c57712f6c1d8e7027aeb (patch)
tree8be2b054aa2eab43f8391b391f72f4b483c9cc6e /actionpack/lib
parent06ac7d3ee0371c3ba20174a5f9fe3830a9d3f6a2 (diff)
downloadrails-efc28a7f701e518eb747c57712f6c1d8e7027aeb.tar.gz
rails-efc28a7f701e518eb747c57712f6c1d8e7027aeb.tar.bz2
rails-efc28a7f701e518eb747c57712f6c1d8e7027aeb.zip
Some small optimizations and improvements to benchmark code.
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/abstract_controller/rendering.rb7
-rw-r--r--actionpack/lib/action_view/lookup_context.rb18
-rw-r--r--actionpack/lib/action_view/template/resolver.rb2
3 files changed, 11 insertions, 16 deletions
diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb
index 41fdc11196..d95770c049 100644
--- a/actionpack/lib/abstract_controller/rendering.rb
+++ b/actionpack/lib/abstract_controller/rendering.rb
@@ -66,12 +66,7 @@ module AbstractController
end
def view_context_class
- @_view_context_class || self.class.view_context_class
- end
-
- def initialize(*)
- @_view_context_class = nil
- super
+ @_view_context_class ||= self.class.view_context_class
end
# An instance of a view class. The default view class is ActionView::Base
diff --git a/actionpack/lib/action_view/lookup_context.rb b/actionpack/lib/action_view/lookup_context.rb
index fa4bf70f77..d26158cefe 100644
--- a/actionpack/lib/action_view/lookup_context.rb
+++ b/actionpack/lib/action_view/lookup_context.rb
@@ -20,7 +20,7 @@ module ActionView
def self.register_detail(name, options = {}, &block)
self.registered_details << name
- initialize = registered_details.map { |n| "self.#{n} = details[:#{n}]" }
+ initialize = registered_details.map { |n| "@details[:#{n}] = details[:#{n}] || default_#{n}" }
Accessors.send :define_method, :"default_#{name}", &block
Accessors.module_eval <<-METHOD, __FILE__, __LINE__ + 1
@@ -29,7 +29,7 @@ module ActionView
end
def #{name}=(value)
- value = Array.wrap(value.presence || default_#{name})
+ value = value.present? ? Array.wrap(value) : default_#{name}
_set_detail(:#{name}, value) if value != @details[:#{name}]
end
@@ -153,14 +153,14 @@ module ActionView
""
end
- parts = name.split('/')
- name = parts.pop
+ prefixes = nil if prefixes.blank?
+ parts = name.split('/')
+ name = parts.pop
- prefixes = if prefixes.blank?
- [parts.join('/')]
- else
- prefixes.map { |prefix| [prefix, *parts].compact.join('/') }
- end
+ return name, prefixes || [""] if parts.empty?
+
+ parts = parts.join('/')
+ prefixes = prefixes ? prefixes.map { |p| "#{p}/#{parts}" } : [parts]
return name, prefixes
end
diff --git a/actionpack/lib/action_view/template/resolver.rb b/actionpack/lib/action_view/template/resolver.rb
index f855ea257c..eb80a865b5 100644
--- a/actionpack/lib/action_view/template/resolver.rb
+++ b/actionpack/lib/action_view/template/resolver.rb
@@ -24,7 +24,7 @@ module ActionView
end
end
- cattr_accessor :caching
+ class_attribute :caching
self.caching = true
class << self