Sha256: 7d1c2ed9cd67e425dc5e04fa8729ac5cade7e4a430022a6598ac3a54d3879338

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

class Usher
  module Util
    class Rails
      
      def self.activate
        rails_version = "#{::Rails::VERSION::MAJOR}.#{::Rails::VERSION::MINOR}"

        case rails_version
        when '2.3'
          ActionController::Routing.module_eval "remove_const(:Routes); Routes = Usher::Interface.for(:rails23)"

        when '2.2'
          Usher::Interface::Rails22::Mapper.module_eval("include ActionController::Resources")
          ActionController::Routing.module_eval "remove_const(:Routes); Routes = Usher::Interface.for(:rails22)"

        when '2.0'
          Usher::Interface::Rails20::Mapper.module_eval("include ActionController::Resources")
          ActionController::Routing.module_eval <<-CODE
            remove_const(:Routes);
            interface = Usher::Interface.for(:rails20);
            interface.configuration_file = File.join(RAILS_ROOT, 'config', 'routes.rb')
            Routes = interface;
          CODE
        when '3.0'
          ActionController::Routing.module_eval <<-CODE
            remove_const(:Routes);
            interface = Usher::Interface.for(:rails20);
            interface.configuration_file = File.join(RAILS_ROOT, 'config', 'routes.rb')
            Routes = interface;
          CODE
        end
      end
      
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
usher-0.8.3 lib/usher/util/rails.rb
usher-0.8.2 lib/usher/util/rails.rb
usher-0.8.1 lib/usher/util/rails.rb