Skip to content

Commit acc6fcc

Browse files
authored
Merge pull request #37 from jgraichen/fix/rfc6570-indirection
fix: Remove unnecessary indirection via build_url_template
2 parents 0b49703 + 132a3bb commit acc6fcc

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a Ch
1313

1414
### Changes
1515

16+
- Optimize named `*_rfc6570` helpers by removing unnecessary indirection
17+
1618
### Fixes
1719

1820
### Breaks

lib/rails/rfc6570.rb

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,15 @@ def define_rfc6570_helpers(name, route, mod, set)
5353

5454
mod.module_eval do
5555
define_method(rfc6570_name) do |**opts|
56-
::Rails::RFC6570.build_url_template(self, route, **opts)
56+
route.to_rfc6570(**opts, ctx: self)
5757
end
5858

5959
define_method(rfc6570_url_name) do |**opts|
60-
::Rails::RFC6570.build_url_template(
61-
self,
62-
route,
63-
**opts,
64-
path_only: false,
65-
)
60+
route.to_rfc6570(**opts, ctx: self, path_only: false)
6661
end
6762

6863
define_method(rfc6570_path_name) do |**opts|
69-
::Rails::RFC6570.build_url_template(
70-
self,
71-
route,
72-
**opts,
73-
path_only: true,
74-
)
64+
route.to_rfc6570(**opts, ctx: self, path_only: true)
7565
end
7666
end
7767

@@ -135,10 +125,6 @@ def params_for(controller, action)
135125
nil
136126
end
137127

138-
def build_url_template(ctx, route, **kwargs)
139-
route.to_rfc6570(ctx: ctx, **kwargs)
140-
end
141-
142128
extend self # rubocop:disable Style/ModuleFunction
143129
end
144130
end

0 commit comments

Comments
 (0)