Skip to content

Commit 28d34ee

Browse files
estolfodblock
authored andcommitted
Move block call to separate method so it can be spied on
1 parent c7f0ac2 commit 28d34ee

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

.rubocop_todo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Metrics/BlockLength:
4444
# Offense count: 10
4545
# Configuration parameters: CountComments.
4646
Metrics/ClassLength:
47-
Max: 302
47+
Max: 305
4848

4949
# Offense count: 30
5050
Metrics/CyclomaticComplexity:

CHANGELOG.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
#### Features
44

55
* Your contribution here.
6-
* [#1944](https://github.com/ruby-grape/grape/pull/1944): Reduced attribute_translator string allocations - [@ericproulx](https://github.com/ericproulx).
7-
* [#1943](https://github.com/ruby-grape/grape/pull/1943): Reduce number of regex string allocations - [@ericproulx](https://github.com/ericproulx).
8-
* [#1942](https://github.com/ruby-grape/grape/pull/1942): Optimized retained memory methods - [@ericproulx](https://github.com/ericproulx).
9-
* [#1941](https://github.com/ruby-grape/grape/pull/1941): Frozen string literal - [@ericproulx](https://github.com/ericproulx).
10-
* [#1940](https://github.com/ruby-grape/grape/pull/1940): Get rid of a needless step in HashWithIndifferentAccess - [@dnesteryuk](https://github.com/dnesteryuk).
11-
* [#1938](https://github.com/ruby-grape/grape/pull/1938): Add project metadata to the gemspec - [@orien](https://github.com/orien).
12-
* [#1920](https://github.com/ruby-grape/grape/pull/1920): Replace Virtus with dry-types - [@dnesteryuk](https://github.com/dnesteryuk).
6+
* [#1944](https://github.com/ruby-grape/grape/pull/1944): Reduces `attribute_translator` string allocations - [@ericproulx](https://github.com/ericproulx).
7+
* [#1943](https://github.com/ruby-grape/grape/pull/1943): Reduces number of regex string allocations - [@ericproulx](https://github.com/ericproulx).
8+
* [#1942](https://github.com/ruby-grape/grape/pull/1942): Optimizes retained memory methods - [@ericproulx](https://github.com/ericproulx).
9+
* [#1941](https://github.com/ruby-grape/grape/pull/1941): Adds frozen string literal - [@ericproulx](https://github.com/ericproulx).
10+
* [#1940](https://github.com/ruby-grape/grape/pull/1940): Gets rid of a needless step in `HashWithIndifferentAccess` - [@dnesteryuk](https://github.com/dnesteryuk).
11+
* [#1938](https://github.com/ruby-grape/grape/pull/1938): Adds project metadata to the gemspec - [@orien](https://github.com/orien).
12+
* [#1920](https://github.com/ruby-grape/grape/pull/1920): Replaces Virtus with dry-types - [@dnesteryuk](https://github.com/dnesteryuk).
13+
* [#1930](https://github.com/ruby-grape/grape/pull/1930): Moves block call to separate method so it can be spied on - [@estolfo](https://github.com/estolfo).
1314

1415
#### Fixes
1516

lib/grape/endpoint.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def run
262262
run_validators validations, request
263263
remove_renamed_params
264264
run_filters after_validations, :after_validation
265-
response_object = @block ? @block.call(self) : nil
265+
response_object = execute
266266
end
267267

268268
run_filters afters, :after
@@ -335,6 +335,10 @@ def remove_renamed_params
335335

336336
private :build_stack, :build_helpers, :remove_renamed_params
337337

338+
def execute
339+
@block ? @block.call(self) : nil
340+
end
341+
338342
def helpers
339343
lazy_initialize! && @helpers
340344
end

0 commit comments

Comments
 (0)