Class: Skylight::Core::Normalizers::RenderNormalizer Private
- Inherits:
-
Normalizer
- Object
- Normalizer
- Skylight::Core::Normalizers::RenderNormalizer
- Includes:
- Util::AllocationFree
- Defined in:
- lib/skylight/core/normalizers/render.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Base Normalizer for Rails rendering
Direct Known Subclasses
ActionView::RenderCollection, ActionView::RenderPartial, ActionView::RenderTemplate
Instance Attribute Summary
Attributes inherited from Normalizer
Instance Method Summary collapse
-
#normalize_render(category, payload) ⇒ Array
private
Generic normalizer for renders.
- #relative_path(path) ⇒ Object private
- #setup ⇒ Object private
Methods included from Util::AllocationFree
Methods inherited from Normalizer
#initialize, #normalize, #normalize_after, register
Constructor Details
This class inherits a constructor from Skylight::Core::Normalizers::Normalizer
Instance Method Details
#normalize_render(category, payload) ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Generic normalizer for renders
16 17 18 19 20 21 22 23 |
# File 'lib/skylight/core/normalizers/render.rb', line 16 def normalize_render(category, payload) if path = payload[:identifier] title = relative_path(path) path = nil if path == title end [ category, title, nil ] end |
#relative_path(path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/skylight/core/normalizers/render.rb', line 25 def relative_path(path) return path if relative_path?(path) root = array_find(@paths) { |p| path.start_with?(p) } type = :project unless root root = array_find(Gem.path) { |p| path.start_with?(p) } type = :gem end if root start = root.size start += 1 if path.getbyte(start) == SEPARATOR_BYTE if type == :gem "$GEM_PATH/#{path[start, path.size]}" else path[start, path.size] end else "Absolute Path" end end |
#setup ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
7 8 9 |
# File 'lib/skylight/core/normalizers/render.rb', line 7 def setup @paths = config['normalizers.render.view_paths'] || [] end |