Class: Happy::Extras::ActionController
- Inherits:
-
Controller
- Object
- Controller
- Happy::Extras::ActionController
- Defined in:
- lib/happy/extras/action_controller.rb
Overview
A Rails-like controller that dispatches to individual actions named in the URL.
The controller’s root URL will call the ‘index` method, any sub-path will call the method by that name. If a third path is provided, it will be assigned to params.
/ # index /foo # foo /foo/123 # foo (with params set to 123)
Constant Summary
Constants inherited from Controller
Controller::CASCADING_SETTINGS
Instance Attribute Summary
Attributes inherited from Controller
#env, #processed_path, #unprocessed_path
Attributes included from Helpers::Rendering
Instance Method Summary collapse
Methods inherited from Controller
#app, #current_url, helpers, #initialize, #params, #request, #response, #root_url, #session
Methods included from Helpers::I18n
Methods included from Helpers::Rendering
#capture_template_block, #concat_output, #render, #render_resource, #render_template, #with_output_buffer
Methods included from Helpers::Html
#escape_html, #html_tag, #html_tag_attributes, #link_to, #preserve, #url_for
Methods included from Controller::Permissions
Methods included from Controller::Configurable
Methods included from Controller::Rackable
Methods included from Controller::Actions
#cache_control, #content_type, #halt!, #header, #layout, #max_age, #only_if_path_matches, #redirect!, #run, #serve!
Methods included from Controller::Routing
Constructor Details
This class inherits a constructor from Happy::Controller
Instance Method Details
#dispatch_to_method(name) ⇒ Object (protected)
30 31 32 33 34 35 36 37 |
# File 'lib/happy/extras/action_controller.rb', line 30 def dispatch_to_method(name) # Only dispatch to public methods if public_methods(false).include?(name.to_sym) send name else raise Errors::NotFound end end |
#route ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/happy/extras/action_controller.rb', line 16 def route on :action do on :id do dispatch_to_method params['action'] end dispatch_to_method params['action'] end index end |