Class: Module

Inherits:
Object
  • Object
show all
Defined in:
brew/Library/Homebrew/extend/module.rb

Instance Method Summary collapse

Instance Method Details

#attr_rw(*attrs) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'brew/Library/Homebrew/extend/module.rb', line 4

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