Class: Usher::Interface::Rails3Interface
- Inherits:
-
Object
- Object
- Usher::Interface::Rails3Interface
- Defined in:
- lib/usher/interface/rails3_interface.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 ⇒ Rails3Interface
constructor
A new instance of Rails3Interface.
- #load(app) ⇒ Object
- #recognize(request) ⇒ Object
- #reload ⇒ Object (also: #reload!)
Constructor Details
#initialize ⇒ Rails3Interface
Returns a new instance of Rails3Interface.
7 8 9 10 11 12 13 |
# File 'lib/usher/interface/rails3_interface.rb', line 7 def initialize @usher = Usher.new @controller_paths = [] @configurations_files = [] @@instance = self end |
Instance Attribute Details
#controller_paths ⇒ Object
Returns the value of attribute controller_paths.
23 24 25 |
# File 'lib/usher/interface/rails3_interface.rb', line 23 def controller_paths @controller_paths end |
Class Method Details
.instance ⇒ Object
15 16 17 |
# File 'lib/usher/interface/rails3_interface.rb', line 15 def self.instance @@instance end |
Instance Method Details
#add_configuration_file(file) ⇒ Object
25 26 27 |
# File 'lib/usher/interface/rails3_interface.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_interface.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_interface.rb', line 19 def draw(&blk) @usher.instance_eval(&blk) end |
#load(app) ⇒ Object
52 53 54 |
# File 'lib/usher/interface/rails3_interface.rb', line 52 def load(app) @app = app end |
#recognize(request) ⇒ Object
46 47 48 49 50 |
# File 'lib/usher/interface/rails3_interface.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_interface.rb', line 29 def reload @usher.reset! @configurations_files.each do |c| Kernel.load(c) end end |