Module: TypedViewModel::Helpers::PathHelpers

Defined in:
lib/typed_view_model/helpers/path_helpers.rb

Overview

Provides access to Rails path/URL helpers in view model objects Include this module when your view model needs to generate paths or URLs

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, **kwargs, &block) ⇒ Object (private)



16
17
18
19
20
21
22
# File 'lib/typed_view_model/helpers/path_helpers.rb', line 16

def method_missing(method_name, *args, **kwargs, &block)
  if method_name.to_s.end_with?("_path", "_url") && url_helpers.respond_to?(method_name)
    url_helpers.public_send(method_name, *args, **kwargs, &block)
  else
    super
  end
end

Instance Method Details

#url_helpersObject

Access to Rails route helpers



9
10
11
# File 'lib/typed_view_model/helpers/path_helpers.rb', line 9

def url_helpers
  Rails.application.routes.url_helpers
end