mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
envutil.rb: Also alias to #name
This commit is contained in:
parent
dc13a98065
commit
f0b5629c8c
1 changed files with 10 additions and 2 deletions
|
@ -244,7 +244,11 @@ module EnvUtil
|
|||
|
||||
def labeled_module(name, &block)
|
||||
Module.new do
|
||||
singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s}
|
||||
singleton_class.class_eval {
|
||||
define_method(:to_s) {name}
|
||||
alias inspect to_s
|
||||
alias name to_s
|
||||
}
|
||||
class_eval(&block) if block
|
||||
end
|
||||
end
|
||||
|
@ -252,7 +256,11 @@ module EnvUtil
|
|||
|
||||
def labeled_class(name, superclass = Object, &block)
|
||||
Class.new(superclass) do
|
||||
singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s}
|
||||
singleton_class.class_eval {
|
||||
define_method(:to_s) {name}
|
||||
alias inspect to_s
|
||||
alias name to_s
|
||||
}
|
||||
class_eval(&block) if block
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue