module Spotlight module ApplicationHelper # Can search for named routes directly in the main app, omitting # the "main_app." prefix def method_missing method, *args, &block if main_app_url_helper?(method) main_app.send(method, *args) else super end end def respond_to?(method) main_app_url_helper?(method) or super end def url_for_document document return nil if document.nil? if current_exhibit spotlight.exhibit_catalog_path(current_exhibit, document) else document end end def curation_mode_label_class if curation_mode? "warning" else "primary" end end def curation_mode? params[:action] == "edit" end private def main_app_url_helper?(method) (method.to_s.end_with?('_path') or method.to_s.end_with?('_url')) and main_app.respond_to?(method) end end end