15 lines
279 B
Ruby
Raw Normal View History

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