Sha256: 390dec0434b4a66fef914b4e31473bbb528b2b10e9c3af4f6565898fab974496

Contents?: true

Size: 946 Bytes

Versions: 1

Compression:

Stored size: 946 Bytes

Contents

module Spotlight
  module ApplicationHelper

    # search_action_url is a special Blacklight helper (not a route),
    # so it doesn't get caught by the method_missing logic below.
    # TODO: we should consider making this configurable
    def search_action_url *args
      if controller_path == 'spotlight/catalog'
        catalog_index_url *args
      else
        main_app.catalog_index_url *args
      end
    end

    # 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

    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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blacklight-spotlight-0.0.1 app/helpers/spotlight/application_helper.rb