Class: Rango::ControllerStrategy
- Rango::RouterStrategy
- Rango::ControllerStrategy
to(“Post#show”, “blog/views”)
> Post.new(request).show(*args)
Public Visibility
Public Instance Method Summary
#match?(request, params, *args, &block) | |
---|---|
#run(request, params, *args, &block) |
Public Instance Methods Inherited from Rango::RouterStrategy
Public Instance Method Details
match?
public
match?(request, params, *args, &block)
[View source]
17 18 19 |
# File 'lib/rango/router/strategies.rb', line 17 def match?(request, params, *args, &block) args.length.eql?(2) && args.all? { |arg| arg.is_a?(String) } && !block_given? end |
run
public
run(request, params, *args, &block)
[View source]
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rango/router/strategies.rb', line 21 def run(request, params, *args, &block) file = args.first callable = args.last Project.import(file) if file.is_a?(String) args = params.map { |key, value| value } klass_name, method = callable.split("#") klass = Object.const_get(klass_name) controller = klass.new controller.request = request controller.params = params controller.method(method).call(*args) end |