lib/apotomo/rails/controller_methods.rb in apotomo-1.0.0.beta1 vs lib/apotomo/rails/controller_methods.rb in apotomo-1.0.0.beta2

- old
+ new

@@ -19,10 +19,19 @@ after_filter :apotomo_freeze end end module ClassMethods + # Yields the root widget to setup your widgets for a controller. The block is executed in + # controller _instance_ context, so you may use instance methods and variables of the + # controller. + # + # Example: + # class PostsController < ApplicationController + # has_widgets do |root| + # root << widget(:comments_widget, 'post-comments', :user => @current_user) + # end def has_widgets(&block) has_widgets_blocks << block end alias_method :uses_widgets, :has_widgets @@ -61,11 +70,11 @@ # Note that the passed block is executed once per session and not in every request. # # Example: # def login # use_widgets do |root| - # root << cell(:login, :form, 'login_box') + # root << widget(:login_widget, 'login_box') # end # # @box = render_widget 'login_box' # end def use_widgets(&block) @@ -109,11 +118,16 @@ apotomo_event_path(apotomo_request_processor.address_for(options)) end protected + def parent_controller + self + end + + # Renders the page updates through an iframe. Copied from responds_to_parent, # see http://github.com/markcatley/responds_to_parent . def render_iframe_updates(page_updates) script = apotomo_request_processor.render_page_updates(page_updates) escaped_script = Apotomo::JavascriptGenerator.escape(script) @@ -156,6 +170,6 @@ super(id_for_proc(proc)) end end end end -end \ No newline at end of file +end