Sha256: 49f231a7c4ac3cb0f77bb875828fbe4e5027e21f372cf67e92727ac54bdbeff8
Contents?: true
Size: 819 Bytes
Versions: 31
Compression:
Stored size: 819 Bytes
Contents
# This extends Class to be able to use +cattr_accessor+ if active_support is not being used. class Class unless respond_to?(:cattr_reader) def cattr_reader(sym) class_eval(<<-EOS, __FILE__, __LINE__ + 1) unless defined? @@#{sym} @@#{sym} = nil end def self.#{sym} @@#{sym} end def #{sym} @@#{sym} end EOS end def cattr_writer(sym) class_eval(<<-EOS, __FILE__, __LINE__ + 1) unless defined? @@#{sym} @@#{sym} = nil end def self.#{sym}=(obj) @@#{sym} = obj end def #{sym}=(obj) @@#{sym} = obj end EOS end def cattr_accessor(*syms, &blk) cattr_reader(*syms) cattr_writer(*syms, &blk) end end end
Version data entries
31 entries across 31 versions & 4 rubygems