Class: Usher::Interface::Rails3
- Inherits:
-
Object
- Object
- Usher::Interface::Rails3
- Defined in:
- lib/usher/interface/rails3.rb
Constant Summary collapse
- @@instance =
nil
Instance Attribute Summary collapse
-
#controller_paths ⇒ Object
Returns the value of attribute controller_paths.
Class Method Summary collapse
Instance Method Summary collapse
- #add_configuration_file(file) ⇒ Object
- #call(env) ⇒ Object
- #draw(&blk) ⇒ Object
-
#initialize ⇒ Rails3
constructor
A new instance of Rails3.
- #load(app) ⇒ Object
- #recognize(request) ⇒ Object
- #reload ⇒ Object (also: #reload!)
Constructor Details
Instance Attribute Details
#controller_paths ⇒ Object
Returns the value of attribute controller_paths.
23 24 25 |
# File 'lib/usher/interface/rails3.rb', line 23 def controller_paths @controller_paths end |
Class Method Details
.instance ⇒ Object
15 16 17 |
# File 'lib/usher/interface/rails3.rb', line 15 def self.instance @@instance end |
Instance Method Details
#add_configuration_file(file) ⇒ Object
25 26 27 |
# File 'lib/usher/interface/rails3.rb', line 25 def add_configuration_file(file) @configurations_files << file end |
#call(env) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/usher/interface/rails3.rb', line 37 def call(env) request = ActionDispatch::Request.new(env) response = @usher.recognize(request, request.path_info) request.parameters.merge!(response.path.route.default_values) if response.path.route.default_values response.params.each{ |hk| request.parameters[hk.first] = hk.last} controller = "#{request.parameters[:controller].to_s.camelize}Controller".constantize controller.action(request.parameters[:action] || 'index').call(env) end |
#draw(&blk) ⇒ Object
19 20 21 |
# File 'lib/usher/interface/rails3.rb', line 19 def draw(&blk) @usher.instance_eval(&blk) end |
#load(app) ⇒ Object
52 53 54 |
# File 'lib/usher/interface/rails3.rb', line 52 def load(app) @app = app end |
#recognize(request) ⇒ Object
46 47 48 49 50 |
# File 'lib/usher/interface/rails3.rb', line 46 def recognize(request) params = recognize_path(request.path, extract_request_environment(request)) request.path_parameters = params.with_indifferent_access "#{params[:controller].to_s.camelize}Controller".constantize end |
#reload ⇒ Object Also known as: reload!
29 30 31 32 33 34 |
# File 'lib/usher/interface/rails3.rb', line 29 def reload @usher.reset! @configurations_files.each do |c| Kernel.load(c) end end |