Sha256: 7dd8250d014468bfc658b5561c8ab00b896f916eac8e8f523d20fa14a4b6dc63
Contents?: true
Size: 843 Bytes
Versions: 2
Compression:
Stored size: 843 Bytes
Contents
# Add `attr_accessor` like methods to modules 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rawler-0.1.3 | lib/rawler/core_extensions/module.rb |
rawler-0.1.1 | lib/rawler/core_extensions/module.rb |