Method: Plezi::Base::Route#initialize
- Defined in:
- lib/plezi/router/route.rb
#initialize(path, controller) ⇒ Route
Returns a new instance of Route.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/plezi/router/route.rb', line 8 def initialize(path, controller) @route_id = "Route#{object_id.to_s(16)}".to_sym @params_range = (0..0) m = path.match(/([^\:\(\*]*)(.*)/) @prefix = m[1].chomp('/'.freeze) if @prefix.nil? || @prefix == ''.freeze @prefix = '/'.freeze @prefix_length = 1 else @prefix = "/#{@prefix}" if @prefix[0] != '/'.freeze @prefix_length = @prefix.length + 1 end @controller = controller @param_names = [] @origial = path.dup.freeze prep_params(m[2]) self.class.qp case @controller when Class prep_controller when Regexp raise "Rewrite Routes can't contain more then one parameter to collect" if @param_names.length > 1 else raise 'Controller should be a class object' unless controller.is_a?(Class) end end |