Class: RbsRails::PathHelpers
- Inherits:
-
Object
- Object
- RbsRails::PathHelpers
- Defined in:
- lib/rbs_rails/path_helpers.rb,
sig/rbs_rails/path_helpers.rbs
Instance Attribute Summary collapse
- #routes ⇒ Object readonly
Class Method Summary collapse
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(routes:) ⇒ PathHelpers
constructor
A new instance of PathHelpers.
Constructor Details
#initialize(routes:) ⇒ PathHelpers
Returns a new instance of PathHelpers.
11 12 13 |
# File 'lib/rbs_rails/path_helpers.rb', line 11 def initialize(routes:) @routes = routes end |
Instance Attribute Details
#routes ⇒ Object (readonly)
42 43 44 |
# File 'lib/rbs_rails/path_helpers.rb', line 42 def routes @routes end |
Class Method Details
.generate(routes: Rails.application.routes) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/rbs_rails/path_helpers.rb', line 3 def self.generate(routes: Rails.application.routes) # Since Rails 8.0, route drawing has been deferred to the first request. # This forcedly loads routes before generating path_helpers. Rails.application.routes.eager_load! new(routes: Rails.application.routes).generate end |
Instance Method Details
#generate ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rbs_rails/path_helpers.rb', line 15 def generate methods = helpers.map do |helper| # TODO: More restrict argument types "def #{helper}: (*untyped) -> ::String" end <<~RBS # resolve-type-names: false interface ::_RbsRailsPathHelpers #{methods.join("\n").indent(2)} end module ::ActionController class ::ActionController::Base include ::_RbsRailsPathHelpers end end RBS end |