Module: Apotomo::Rails::ControllerMethods
- Extended by:
- ActiveSupport::Concern
- Includes:
- WidgetShortcuts
- Defined in:
- lib/apotomo/rails/controller_methods.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #apotomo_request_processor ⇒ Object
- #apotomo_root ⇒ Object
- #render_event_response ⇒ Object
- #render_widget(*args, &block) ⇒ Object
-
#url_for_event(type, options) ⇒ Object
Returns the url to trigger a
type
event from:source
, which is a non-optional parameter.
Methods included from WidgetShortcuts
Instance Method Details
#apotomo_request_processor ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/apotomo/rails/controller_methods.rb', line 48 def apotomo_request_processor return @apotomo_request_processor if @apotomo_request_processor # happens once per request: = {:js_framework => Apotomo.js_framework} @apotomo_request_processor = Apotomo::RequestProcessor.new(self, , self.class.) end |
#apotomo_root ⇒ Object
57 58 59 |
# File 'lib/apotomo/rails/controller_methods.rb', line 57 def apotomo_root apotomo_request_processor.root end |
#render_event_response ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/apotomo/rails/controller_methods.rb', line 65 def render_event_response page_updates = apotomo_request_processor.process_for(params) return render_iframe_updates(page_updates) if params[:apotomo_iframe] render :text => page_updates.join("\n"), :content_type => Mime::JS end |
#render_widget(*args, &block) ⇒ Object
61 62 63 |
# File 'lib/apotomo/rails/controller_methods.rb', line 61 def (*args, &block) apotomo_request_processor.(*args, &block) end |
#url_for_event(type, options) ⇒ Object
Returns the url to trigger a type
event from :source
, which is a non-optional parameter. Additional options
will be appended to the query string.
Note that this method will use the framework’s internal routing if available (e.g. #url_for in Rails).
Example:
url_for_event(:paginate, :source => 'mouse', :page => 2)
#=> http://apotomo.de/mouse/process_event_request?type=paginate&source=mouse&page=2
81 82 83 84 85 |
# File 'lib/apotomo/rails/controller_methods.rb', line 81 def url_for_event(type, ) .reverse_merge!(:type => type) apotomo_event_path(apotomo_request_processor.address_for()) end |