Module: Mojito::ClassMethods
- Defined in:
- lib/mojito.rb,
lib/mojito/base.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
- #controller(name, options = {}) ⇒ Object
- #dispatch(request) ⇒ Object
- #helper(name, options = {}) ⇒ Object
- #mock_request ⇒ Object
- #rendering(name, options = {}) ⇒ Object
Instance Method Details
#call(env) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/mojito/base.rb', line 64 def call(env) catch :halt do request = Rack::Request.new env dispatch request end end |
#controller(name, options = {}) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/mojito.rb', line 43 def controller(name, = {}) mod = Mojito::Controllers.const_get name.to_s.camel_case.to_sym [*[:rendering]].each {|r| rendering r } [*[:helpers]].each {|h| helper h } include mod end |
#dispatch(request) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/mojito/base.rb', line 71 def dispatch(request) controller = self.new request begin controller.__dispatch rescue Exception => e if controller.respond_to? :__handle_error controller.__handle_error(e) else raise e end end end |
#helper(name, options = {}) ⇒ Object
50 51 52 53 |
# File 'lib/mojito.rb', line 50 def helper(name, = {}) mod = Mojito::Helpers.const_get name.to_s.camel_case.to_sym include mod end |
#mock_request ⇒ Object
39 40 41 |
# File 'lib/mojito.rb', line 39 def mock_request Rack::MockRequest.new self end |