aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib
diff options
context:
space:
mode:
authorGenadi Samokovarov <gsamokovarov@gmail.com>2016-05-30 14:53:03 +0300
committerGenadi Samokovarov <gsamokovarov@gmail.com>2016-05-30 14:53:03 +0300
commita11a3861b474ef642ac48796572d6276436c7eb0 (patch)
tree5e7da0567079981991e9a23696c7d20faf4c9f2b /actionview/lib
parente6ed3aaf437887bc25a1f715f21c5ca3ebbc966f (diff)
parent3f2e83d964fcb4cd7f7f2ed8fb2b2592ffc57647 (diff)
downloadrails-a11a3861b474ef642ac48796572d6276436c7eb0.tar.gz
rails-a11a3861b474ef642ac48796572d6276436c7eb0.tar.bz2
rails-a11a3861b474ef642ac48796572d6276436c7eb0.zip
Merge branch 'master' into always-inherit-from-application-record
Diffstat (limited to 'actionview/lib')
-rw-r--r--actionview/lib/action_view/digestor.rb9
-rw-r--r--actionview/lib/action_view/gem_version.rb4
-rw-r--r--actionview/lib/action_view/helpers/cache_helper.rb6
-rw-r--r--actionview/lib/action_view/helpers/form_tag_helper.rb4
-rw-r--r--actionview/lib/action_view/lookup_context.rb12
-rw-r--r--actionview/lib/action_view/railtie.rb12
-rw-r--r--actionview/lib/action_view/renderer/template_renderer.rb6
-rw-r--r--actionview/lib/action_view/template/resolver.rb17
8 files changed, 37 insertions, 33 deletions
diff --git a/actionview/lib/action_view/digestor.rb b/actionview/lib/action_view/digestor.rb
index b99d1af998..b91e61da18 100644
--- a/actionview/lib/action_view/digestor.rb
+++ b/actionview/lib/action_view/digestor.rb
@@ -4,14 +4,7 @@ require 'monitor'
module ActionView
class Digestor
- @@digest_mutex = Mutex.new
-
- class PerRequestDigestCacheExpiry < Struct.new(:app) # :nodoc:
- def call(env)
- ActionView::LookupContext::DetailsKey.clear
- app.call(env)
- end
- end
+ @@digest_mutex = Mutex.new
class << self
# Supported options:
diff --git a/actionview/lib/action_view/gem_version.rb b/actionview/lib/action_view/gem_version.rb
index efb565bf59..5fc4f3f1b9 100644
--- a/actionview/lib/action_view/gem_version.rb
+++ b/actionview/lib/action_view/gem_version.rb
@@ -6,9 +6,9 @@ module ActionView
module VERSION
MAJOR = 5
- MINOR = 0
+ MINOR = 1
TINY = 0
- PRE = "beta3"
+ PRE = "alpha"
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
end
diff --git a/actionview/lib/action_view/helpers/cache_helper.rb b/actionview/lib/action_view/helpers/cache_helper.rb
index 4c7c4b91c6..4eaaa239e2 100644
--- a/actionview/lib/action_view/helpers/cache_helper.rb
+++ b/actionview/lib/action_view/helpers/cache_helper.rb
@@ -41,11 +41,11 @@ module ActionView
#
# ==== \Template digest
#
- # The template digest that's added to the cache key is computed by taking an md5 of the
+ # The template digest that's added to the cache key is computed by taking an MD5 of the
# contents of the entire template file. This ensures that your caches will automatically
# expire when you change the template file.
#
- # Note that the md5 is taken of the entire template file, not just what's within the
+ # Note that the MD5 is taken of the entire template file, not just what's within the
# cache do/end call. So it's possible that changing something outside of that call will
# still expire the cache.
#
@@ -118,7 +118,7 @@ module ActionView
#
# If you use a helper method, for example, inside a cached block and
# you then update that helper, you'll have to bump the cache as well.
- # It doesn't really matter how you do it, but the md5 of the template file
+ # It doesn't really matter how you do it, but the MD5 of the template file
# must change. One recommendation is to simply be explicit in a comment, like:
#
# <%# Helper Dependency Updated: May 6, 2012 at 6pm %>
diff --git a/actionview/lib/action_view/helpers/form_tag_helper.rb b/actionview/lib/action_view/helpers/form_tag_helper.rb
index cfff0bef5d..82f2fd30c7 100644
--- a/actionview/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionview/lib/action_view/helpers/form_tag_helper.rb
@@ -134,13 +134,15 @@ module ActionView
if options.include?(:include_blank)
include_blank = options.delete(:include_blank)
+ options_for_blank_options_tag = { value: '' }
if include_blank == true
include_blank = ''
+ options_for_blank_options_tag[:label] = ' '
end
if include_blank
- option_tags = content_tag("option".freeze, include_blank, value: '').safe_concat(option_tags)
+ option_tags = content_tag("option".freeze, include_blank, options_for_blank_options_tag).safe_concat(option_tags)
end
end
diff --git a/actionview/lib/action_view/lookup_context.rb b/actionview/lib/action_view/lookup_context.rb
index 626c4b8f5e..9db1460ee7 100644
--- a/actionview/lib/action_view/lookup_context.rb
+++ b/actionview/lib/action_view/lookup_context.rb
@@ -63,7 +63,7 @@ module ActionView
details = details.dup
details[:formats] &= Template::Types.symbols
end
- @details_keys[details] ||= new
+ @details_keys[details] ||= Concurrent::Map.new
end
def self.clear
@@ -71,13 +71,7 @@ module ActionView
end
def self.digest_caches
- @details_keys.values.map(&:digest_cache)
- end
-
- attr_reader :digest_cache
-
- def initialize
- @digest_cache = Concurrent::Map.new
+ @details_keys.values
end
end
@@ -236,7 +230,7 @@ module ActionView
end
def digest_cache
- details_key.digest_cache
+ details_key
end
def initialize_details(target, details)
diff --git a/actionview/lib/action_view/railtie.rb b/actionview/lib/action_view/railtie.rb
index 67c80d22d8..dfb99f4ea9 100644
--- a/actionview/lib/action_view/railtie.rb
+++ b/actionview/lib/action_view/railtie.rb
@@ -37,16 +37,10 @@ module ActionView
end
end
- initializer "action_view.collection_caching", after: "action_controller.set_configs" do |app|
- ActiveSupport.on_load(:action_controller) do
- PartialRenderer.collection_cache = app.config.action_controller.cache_store
- end
- end
-
initializer "action_view.per_request_digest_cache" do |app|
ActiveSupport.on_load(:action_view) do
if app.config.consider_all_requests_local
- app.middleware.use ActionView::Digestor::PerRequestDigestCacheExpiry
+ app.executor.to_run { ActionView::LookupContext::DetailsKey.clear }
end
end
end
@@ -57,6 +51,10 @@ module ActionView
end
end
+ initializer "action_view.collection_caching", after: "action_controller.set_configs" do |app|
+ PartialRenderer.collection_cache = app.config.action_controller.cache_store
+ end
+
rake_tasks do |app|
unless app.config.api_only
load "action_view/tasks/cache_digests.rake"
diff --git a/actionview/lib/action_view/renderer/template_renderer.rb b/actionview/lib/action_view/renderer/template_renderer.rb
index 9d15bbfca7..1d6afb90fe 100644
--- a/actionview/lib/action_view/renderer/template_renderer.rb
+++ b/actionview/lib/action_view/renderer/template_renderer.rb
@@ -84,13 +84,13 @@ module ActionView
when String
begin
if layout =~ /^\//
- with_fallbacks { find_template(layout, nil, false, keys, details) }
+ with_fallbacks { find_template(layout, nil, false, [], details) }
else
- find_template(layout, nil, false, keys, details)
+ find_template(layout, nil, false, [], details)
end
rescue ActionView::MissingTemplate
all_details = @details.merge(:formats => @lookup_context.default_formats)
- raise unless template_exists?(layout, nil, false, keys, all_details)
+ raise unless template_exists?(layout, nil, false, [], all_details)
end
when Proc
resolve_layout(layout.call(formats), keys, formats)
diff --git a/actionview/lib/action_view/template/resolver.rb b/actionview/lib/action_view/template/resolver.rb
index c5e69b1833..bf68e93c58 100644
--- a/actionview/lib/action_view/template/resolver.rb
+++ b/actionview/lib/action_view/template/resolver.rb
@@ -88,6 +88,23 @@ module ActionView
@query_cache.clear
end
+ # Get the cache size. Do not call this
+ # method. This method is not guaranteed to be here ever.
+ def size # :nodoc:
+ size = 0
+ @data.each_value do |v1|
+ v1.each_value do |v2|
+ v2.each_value do |v3|
+ v3.each_value do |v4|
+ size += v4.size
+ end
+ end
+ end
+ end
+
+ size + @query_cache.size
+ end
+
private
def canonical_no_templates(templates)