mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Add require to Delegator examples
In Ruby 2.7.1 SimpeDelegator cannot be used without requiring `delegate` this PR adds the require to the first example for each class so that devs don't have to hunt for what require to use.
This commit is contained in:
parent
6fdd5e26c6
commit
2d89af45ea
Notes:
git
2020-06-26 00:21:52 +09:00
1 changed files with 4 additions and 0 deletions
|
@ -21,6 +21,8 @@
|
||||||
# SimpleDelegator's implementation serves as a nice example of the use of
|
# SimpleDelegator's implementation serves as a nice example of the use of
|
||||||
# Delegator:
|
# Delegator:
|
||||||
#
|
#
|
||||||
|
# require 'delegate'
|
||||||
|
#
|
||||||
# class SimpleDelegator < Delegator
|
# class SimpleDelegator < Delegator
|
||||||
# def __getobj__
|
# def __getobj__
|
||||||
# @delegate_sd_obj # return object we are delegating to, required
|
# @delegate_sd_obj # return object we are delegating to, required
|
||||||
|
@ -253,6 +255,8 @@ end
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
|
# require 'delegate'
|
||||||
|
#
|
||||||
# class UserDecorator < SimpleDelegator
|
# class UserDecorator < SimpleDelegator
|
||||||
# def birth_year
|
# def birth_year
|
||||||
# born_on.year
|
# born_on.year
|
||||||
|
|
Loading…
Reference in a new issue