aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/abstract_controller/view_paths.rb
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2013-08-26 03:07:30 -0700
committerPiotr Sarnacki <drogus@gmail.com>2013-08-26 03:07:30 -0700
commitc19958015fac7b50f8dedbdf17991c00d6b8bbd4 (patch)
tree42431a33fd65c954b1242b8ff6116163c9969924 /actionpack/lib/abstract_controller/view_paths.rb
parent27dc4fa28ee098d70a11829ad5fa4af0c54e880b (diff)
parent0d43df7ebf7587f032e3b16c153bf35746878c46 (diff)
downloadrails-c19958015fac7b50f8dedbdf17991c00d6b8bbd4.tar.gz
rails-c19958015fac7b50f8dedbdf17991c00d6b8bbd4.tar.bz2
rails-c19958015fac7b50f8dedbdf17991c00d6b8bbd4.zip
Merge pull request #11396 from strzalek/extract_renderers
Remove dependency on Action View from Action Pack This set of changes removes the need of using Action View with Action Pack. Now you may use controllers without Action View, by rendering `:text` response or alternatively you can plug in your own rendering logic. This is especially handy when you're just dealing with APIs and don't need to include entire Action View just to render simple JSON responses.
Diffstat (limited to 'actionpack/lib/abstract_controller/view_paths.rb')
-rw-r--r--actionpack/lib/abstract_controller/view_paths.rb96
1 files changed, 0 insertions, 96 deletions
diff --git a/actionpack/lib/abstract_controller/view_paths.rb b/actionpack/lib/abstract_controller/view_paths.rb
deleted file mode 100644
index c08b3a0e2a..0000000000
--- a/actionpack/lib/abstract_controller/view_paths.rb
+++ /dev/null
@@ -1,96 +0,0 @@
-require 'action_view/base'
-
-module AbstractController
- module ViewPaths
- extend ActiveSupport::Concern
-
- included do
- class_attribute :_view_paths
- self._view_paths = ActionView::PathSet.new
- self._view_paths.freeze
- end
-
- delegate :template_exists?, :view_paths, :formats, :formats=,
- :locale, :locale=, :to => :lookup_context
-
- module ClassMethods
- def parent_prefixes
- @parent_prefixes ||= begin
- parent_controller = superclass
- prefixes = []
-
- until parent_controller.abstract?
- prefixes << parent_controller.controller_path
- parent_controller = parent_controller.superclass
- end
-
- prefixes
- end
- end
- end
-
- # The prefixes used in render "foo" shortcuts.
- def _prefixes
- @_prefixes ||= begin
- parent_prefixes = self.class.parent_prefixes
- parent_prefixes.dup.unshift(controller_path)
- end
- end
-
- # LookupContext is the object responsible to hold all information required to lookup
- # templates, i.e. view paths and details. Check ActionView::LookupContext for more
- # information.
- def lookup_context
- @_lookup_context ||=
- ActionView::LookupContext.new(self.class._view_paths, details_for_lookup, _prefixes)
- end
-
- def details_for_lookup
- { }
- end
-
- def append_view_path(path)
- lookup_context.view_paths.push(*path)
- end
-
- def prepend_view_path(path)
- lookup_context.view_paths.unshift(*path)
- end
-
- module ClassMethods
- # Append a path to the list of view paths for this controller.
- #
- # ==== Parameters
- # * <tt>path</tt> - If a String is provided, it gets converted into
- # the default view path. You may also provide a custom view path
- # (see ActionView::PathSet for more information)
- def append_view_path(path)
- self._view_paths = view_paths + Array(path)
- end
-
- # Prepend a path to the list of view paths for this controller.
- #
- # ==== Parameters
- # * <tt>path</tt> - If a String is provided, it gets converted into
- # the default view path. You may also provide a custom view path
- # (see ActionView::PathSet for more information)
- def prepend_view_path(path)
- self._view_paths = ActionView::PathSet.new(Array(path) + view_paths)
- end
-
- # A list of all of the default view paths for this controller.
- def view_paths
- _view_paths
- end
-
- # Set the view paths.
- #
- # ==== Parameters
- # * <tt>paths</tt> - If a PathSet is provided, use that;
- # otherwise, process the parameter into a PathSet.
- def view_paths=(paths)
- self._view_paths = ActionView::PathSet.new(Array(paths))
- end
- end
- end
-end