Sha256: e866377da85270af41e815bef202e98037df8ad4fc0e83b10832e565428a8303

Contents?: true

Size: 677 Bytes

Versions: 9

Compression:

Stored size: 677 Bytes

Contents

# frozen_string_literal: true
module Thredded
  # If thredded is rendered within an application layout, this module allows
  # referring to the routes in the layout directly, without having to use `main_app.`.
  module MainAppRouteDelegator
    # delegate url helpers to main_app
    def method_missing(method, *args, &block)
      if main_app_route_method?(method)
        main_app.send(method, *args)
      else
        super
      end
    end

    def respond_to?(method, *args)
      super || main_app_route_method?(method)
    end

    private

    def main_app_route_method?(method)
      method.to_s =~ /_(?:path|url)$/ && main_app.respond_to?(method)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
thredded-0.6.2 lib/thredded/main_app_route_delegator.rb
thredded-0.6.1 lib/thredded/main_app_route_delegator.rb
thredded-0.6.0 lib/thredded/main_app_route_delegator.rb
thredded-0.5.1 lib/thredded/main_app_route_delegator.rb
thredded-0.5.0 lib/thredded/main_app_route_delegator.rb
thredded-0.4.0 lib/thredded/main_app_route_delegator.rb
thredded-0.3.2 lib/thredded/main_app_route_delegator.rb
thredded-0.3.1 lib/thredded/main_app_route_delegator.rb
thredded-0.3.0 lib/thredded/main_app_route_delegator.rb