aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend/module.rb
blob: f4ea4de55a6daa3ed52b7532600561390c999ebd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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)
          val.nil? ? @#{attr} : @#{attr} = val
        end
      EOS
    end
  end
end