Skip to content

Instantly share code, notes, and snippets.

@chikamichi
Created March 19, 2011 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chikamichi/877737 to your computer and use it in GitHub Desktop.
Save chikamichi/877737 to your computer and use it in GitHub Desktop.
Apotomo support for builders
# in lib/apotomo/widget.rb
# This comes redundant with Cells internals, but this is due to what may be a flaw in current Apotomo's design,
# which bypass Cells workflow (render_cell_for) and hook directly into AbstractController::Rendering #render_state
# Renders the +widget+ (instance or id).
def render_widget(widget_id, state=:display, *args)
if widget_id.kind_of?(Widget)
widget = widget_id
else
widget = find_widget(widget_id) or raise "Couldn't render non-existent widget `#{widget_id}`"
end
# *** added ***
# Ensure the proper widget class is used in case the widget delegates to some other fellow
target_class = self.class.build_class_for(parent_controller, widget.class, args.first)
if widget.class != target_class
widget = target_class.new(parent_controller, widget_id, args.first)
end
# *** /added ***
widget.invoke(state, *args)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment