Class: UnusedView::Layout
- Inherits:
-
Object
- Object
- UnusedView::Layout
- Defined in:
- lib/unused_view/layout.rb
Instance Method Summary collapse
- #find_all ⇒ Object
-
#initialize(controllers) ⇒ Layout
constructor
A new instance of Layout.
- #name(controller) ⇒ Object
Constructor Details
#initialize(controllers) ⇒ Layout
Returns a new instance of Layout.
5 6 7 |
# File 'lib/unused_view/layout.rb', line 5 def initialize(controllers) @controllers = controllers end |
Instance Method Details
#find_all ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/unused_view/layout.rb', line 9 def find_all @controllers.reduce([]) do |layouts, controller| if _name = name(controller) begin layouts << controller.lookup_context.find(_name, 'layouts') rescue layouts end else layouts end end.uniq.compact.map(&:identifier) end |
#name(controller) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/unused_view/layout.rb', line 23 def name(controller) _name = controller.send(:_layout) rescue nil case _name when String _name when ActionView::Template File.basename(_name.identifier).split('.').first end end |