Class: Module

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

Instance Method Summary collapse

Instance Method Details

#attr_rw(*attrs) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
# File 'Library/Homebrew/extend/module.rb', line 2

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)
        val.nil? ? @#{attr} : @#{attr} = val
      end
    EOS
  end
end