Sha256: 693968fb9ecfa1db8e51f7a4c40c567418e4ea6bdc800740e4362a1db4a8e1cc
Contents?: true
Size: 768 Bytes
Versions: 5
Compression:
Stored size: 768 Bytes
Contents
class Module def mattr_reader(*syms) syms.each do |sym| next if sym.is_a?(Hash) class_eval(<<-EOS, __FILE__, __LINE__) unless defined? @@#{sym} @@#{sym} = nil end def self.#{sym} @@#{sym} end def #{sym} @@#{sym} end EOS end end def mattr_writer(*syms) syms.each do |sym| class_eval(<<-EOS, __FILE__, __LINE__) unless defined? @@#{sym} @@#{sym} = nil end def self.#{sym}=(obj) @@#{sym} = obj end #{" def #{sym}=(obj) @@#{sym} = obj end "} EOS end end def mattr_accessor(*syms) mattr_reader(*syms) mattr_writer(*syms) end end
Version data entries
5 entries across 5 versions & 1 rubygems