aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend/module.rb
blob: 045508fd12c42400430193b444677b7270d090c1 (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