Skip to content

Commit 74e21ab

Browse files
jkowensdblock
authored andcommitted
Refactor #generate_api_method to improve performance (#1726)
1 parent fda88b5 commit 74e21ab

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* [#1722](https://github.com/ruby-grape/grape/pull/1722): Fix catch-all hiding multiple versions of an endpoint after the first definition - [@zherr](https://github.com/zherr).
1414
* [#1724](https://github.com/ruby-grape/grape/pull/1724): Optional nested array validation - [@ericproulx](https://github.com/ericproulx).
1515
* [#1725](https://github.com/ruby-grape/grape/pull/1725): Fix `rescue_from :all` documentation - [@Jelkster](https://github.com/Jelkster).
16+
* [#1726](https://github.com/ruby-grape/grape/pull/1726): Improved startup performance during API method generation - [@jkowens](https://github.com/jkowens).
1617
* Your contribution here.
1718

1819
### 1.0.1 (9/8/2017)

lib/grape/endpoint.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def run_before_each(endpoint)
4444
# @return [Proc]
4545
# @raise [NameError] an instance method with the same name already exists
4646
def generate_api_method(method_name, &block)
47-
if instance_methods.include?(method_name.to_sym) || instance_methods.include?(method_name.to_s)
47+
if method_defined?(method_name)
4848
raise NameError.new("method #{method_name.inspect} already exists and cannot be used as an unbound method name")
4949
end
5050

0 commit comments

Comments
 (0)