Module: YiffSpace::Utils::Routes

Defined in:
lib/yiffspace/utils/routes.rb

Overview

Allow Rails URL helpers to be used outside of views.

Examples:

Routes.posts_path(tags: "male")
=> "/posts?tags=male"

See Also:

Class Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object (private)



16
17
18
# File 'lib/yiffspace/utils/routes.rb', line 16

def method_missing(name, *, &)
  target.send(name, *, &)
end

Class Method Details

.method_missing(name) ⇒ Object



16
17
18
# File 'lib/yiffspace/utils/routes.rb', line 16

def method_missing(name, *, &)
  target.send(name, *, &)
end

.respond_to_missing?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/yiffspace/utils/routes.rb', line 20

def respond_to_missing?(...)
  target.respond_to?(...)
end

.targetObject

Lazily resolved so application is not referenced at load time.



27
28
29
# File 'lib/yiffspace/utils/routes.rb', line 27

def target
  Rails.application.routes.url_helpers
end