require 'fiona7/mode_switch/abstract_mode_switch' module Fiona7 module ModeSwitch class Views < AbstractModeSwitch def standalone self.reorder_view_paths(self.scrivito_sdk_path, self.fiona_connector_path) end def legacy self.reorder_view_paths(self.fiona_connector_path, self.scrivito_sdk_path) end protected def scrivito_sdk_path Gem.loaded_specs['scrivito_sdk'].full_name end def fiona_connector_path Gem.loaded_specs['infopark_fiona_connector'].full_name end def reorder_view_paths(first, second) view_paths = ActionController::Base.view_paths paths = view_paths.map(&:to_s) internal_paths = view_paths.send(:paths) first_index = paths.index {|path| path =~ /#{Regexp.escape first}\/app\/views/ } second_index = paths.index {|path| path =~ /#{Regexp.escape second}\/app\/views/ } if first_index > second_index internal_paths[first_index], internal_paths[second_index] = internal_paths[second_index], internal_paths[first_index] end end end end end