rails/init.rb in usher-0.5.11 vs rails/init.rb in usher-0.5.12
- old
+ new
@@ -1,8 +1,24 @@
-if Rails::VERSION::MAJOR == 2 && Rails::VERSION::MINOR == 3
- ActionController::Routing.module_eval "remove_const(:Routes); Routes = Usher::Interface.for(:rails2_3)"
-elsif Rails::VERSION::MAJOR == 2 && Rails::VERSION::MINOR >= 2
- class Usher::Interface::Rails2_2Interface::Mapper
- include ActionController::Resources
- end
- ActionController::Routing.module_eval "remove_const(:Routes); Routes = Usher::Interface.for(:rails2_2)"
-end
+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'
+ class Usher::Interface::Rails22::Mapper
+ include ActionController::Resources
+ end
+ ActionController::Routing.module_eval "remove_const(:Routes); Routes = Usher::Interface.for(:rails22)"
+
+ when '2.0'
+ class Usher::Interface::Rails20::Mapper
+ include ActionController::Resources
+ end
+
+ 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
\ No newline at end of file