Module: Thredded::Workgroup::RouteDelegator

Defined in:
lib/thredded/workgroup/route_delegator.rb

Class Method Summary collapse

Class Method Details

.add_my_proxies_to_threddedObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/thredded/workgroup/route_delegator.rb', line 8

def self.add_my_proxies_to_thredded
  thredded_methods = Thredded::Engine.routes.url_helpers.methods
  my_route_helpers = Thredded::Workgroup::Engine.routes.url_helpers
  path_methods = my_route_helpers.methods.select { |s| s.to_s.ends_with?("_path", "_url") }
    .reject { |s| thredded_methods.include?(s) }
  path_methods.each do |method_name|
    send(:define_method, method_name) do |*args|
      my_route_helpers.send(method_name, *args)
    end
  end
  ::Thredded::ApplicationController.send(:include,
                                         ::Thredded::Workgroup::RouteDelegator)
  # if we need to use in views, then we add
  # ::Thredded::ApplicationController.helper(::Thredded::Workgroup::RouteDelegator)
end