Sha256: 3281dc8213b4b6a25f9fe1e2ffdc10aa555e7a02f747ef5a75fe05a5309ef46d

Contents?: true

Size: 1.13 KB

Versions: 28

Compression:

Stored size: 1.13 KB

Contents

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

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
infopark_fiona7-1.6.1.1.5 lib/fiona7/mode_switch/views.rb
infopark_fiona7-1.6.1.1.1 lib/fiona7/mode_switch/views.rb
infopark_fiona7-1.6.1.1.0 lib/fiona7/mode_switch/views.rb
infopark_fiona7-1.2.0.2.3 lib/fiona7/mode_switch/views.rb
infopark_fiona7-1.2.0.2.1 lib/fiona7/mode_switch/views.rb
infopark_fiona7-1.2.0.2.2 lib/fiona7/mode_switch/views.rb
infopark_fiona7-1.5.5.5.1 lib/fiona7/mode_switch/views.rb
infopark_fiona7-1.5.5.5.0 lib/fiona7/mode_switch/views.rb
infopark_fiona7-1.2.0.1.4 lib/fiona7/mode_switch/views.rb
infopark_fiona7-1.5.5.4.1 lib/fiona7/mode_switch/views.rb
infopark_fiona7-1.5.5.4.0 lib/fiona7/mode_switch/views.rb
infopark_fiona7-1.2.0.1.3 lib/fiona7/mode_switch/views.rb
infopark_fiona7-1.5.5.3.1 lib/fiona7/mode_switch/views.rb
infopark_fiona7-1.5.4.3.0 lib/fiona7/mode_switch/views.rb
infopark_fiona7-1.5.3.2.0 lib/fiona7/mode_switch/views.rb
infopark_fiona7-1.5.3.2.0.pre.beta1 lib/fiona7/mode_switch/views.rb
infopark_fiona7-1.5.2.1.0.pre.beta1 lib/fiona7/mode_switch/views.rb
infopark_fiona7-1.5.2.0.0 lib/fiona7/mode_switch/views.rb
infopark_fiona7-1.2.0.1.1 lib/fiona7/mode_switch/views.rb
infopark_fiona7-1.2.0.0.1 lib/fiona7/mode_switch/views.rb