Skip to content

Commit 5203702

Browse files
authored
Merge pull request #2581 from ericproulx/instance_to_s_delegation
Delegate #to_s to @instance in Grape::API::Instance
2 parents ea45bc1 + 954cc15 commit 5203702

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* [#2575](https://github.com/ruby-grape/grape/pull/2575): Refactor Api description class - [@ericproulx](https://github.com/ericproulx).
88
* [#2577](https://github.com/ruby-grape/grape/pull/2577): Deprecate `return` in endpoint execution - [@ericproulx](https://github.com/ericproulx).
99
* [#2580](https://github.com/ruby-grape/grape/pull/2580): Refactor endpoint helpers and error middleware integration - [@ericproulx](https://github.com/ericproulx).
10+
* [#2581](https://github.com/ruby-grape/grape/pull/2581): Delegate `to_s` in Grape::API::Instance - [@ericproulx](https://github.com/ericproulx).
1011
* [#2582](https://github.com/ruby-grape/grape/pull/2582): Fix leaky slash when normalizing - [@ericproulx](https://github.com/ericproulx).
1112
* Your contribution here.
1213

lib/grape/api/instance.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,16 @@ class Instance
1919
Boolean = Grape::API::Boolean
2020

2121
class << self
22+
extend Forwardable
2223
attr_reader :instance, :base
2324
attr_accessor :configuration
2425

26+
def_delegators :base, :to_s
27+
2528
def given(conditional_option, &block)
26-
evaluate_as_instance_with_configuration(block, lazy: true) if conditional_option && block
29+
return unless conditional_option
30+
31+
mounted(&block)
2732
end
2833

2934
def mounted(&block)
@@ -35,10 +40,6 @@ def base=(grape_api)
3540
grape_api.instances << self
3641
end
3742

38-
def to_s
39-
base&.to_s || super
40-
end
41-
4243
def base_instance?
4344
self == base.base_instance
4445
end

0 commit comments

Comments
 (0)