Class: Ferret::Browser::Delegator
- Inherits:
-
Object
- Object
- Ferret::Browser::Delegator
- Defined in:
- lib/ferret/browser.rb
Instance Method Summary collapse
-
#initialize(reader, path) ⇒ Delegator
constructor
A new instance of Delegator.
- #run(env) ⇒ Object
Constructor Details
#initialize(reader, path) ⇒ Delegator
Returns a new instance of Delegator.
6 7 8 |
# File 'lib/ferret/browser.rb', line 6 def initialize(reader, path) @reader, @path = reader, path end |
Instance Method Details
#run(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ferret/browser.rb', line 10 def run(env) controller, action, args = :home, :index, nil query_string = env['QUERY_STRING']||'' params = parse_query_string(query_string) req_path = env['PATH_INFO'].gsub(/\/+/, '/') case req_path when '/' # nothing to do when /^\/?([-a-zA-Z]+)\/?$/ controller = $1 when /^\/?([-a-zA-Z]+)\/([-a-zA-Z]+)\/?(.*)?$/ controller = $1 action = $2 args = $3 else controller = :error args = req_path end controller_vars = { :params => params, :req_path => req_path, :query_string => query_string, } delegate(controller, action, args, controller_vars) end |