mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-15 19:56:59 +08:00
20 lines
366 B
Ruby
20 lines
366 B
Ruby
# typed: false
|
|
# frozen_string_literal: true
|
|
|
|
class Module
|
|
def attr_rw(*attrs)
|
|
file, line, = caller.first.split(":")
|
|
line = line.to_i
|
|
|
|
attrs.each do |attr|
|
|
module_eval <<-EOS, file, line
|
|
def #{attr}(val=nil)
|
|
@#{attr} ||= nil
|
|
return @#{attr} if val.nil?
|
|
@#{attr} = val
|
|
end
|
|
EOS
|
|
end
|
|
end
|
|
end
|