Sha256: 0dfd8a5e428824a061bf8ea5ced3363b1bf78a1568c1af21bc9e6e2b0fe5b6ec
Contents?: true
Size: 1023 Bytes
Versions: 1
Compression:
Stored size: 1023 Bytes
Contents
# #class Symbol # def ~@ # return self, "#{self}=".intern # end #end class Object def iv; @iv; end private :iv end class Module def var(*vars) vars.flatten.each do |v| s = v.to_s case s[-1..-1] when '=' s = s[0..-2] class_eval <<-EOS def #{s}=(arg) iv[:#{s}] = arg iv[:#{s}] end EOS else class_eval <<-EOS def #{v}(*args) iv[:#{v}] = args[0] if !args.empty? iv[:#{v}] end EOS end end return *vars end end class Class alias_method :new_orig, :new def new(*args, &block) o = new_orig(*args, &block) o.instance_variable_set('@iv',{}) o end end class Module PVars = {} #def var(*vars) # vars.each do |v| # class_eval <<-EOS # def #{v}(*args) # PVars[self] ||= {} # PVars[self][#{v}] = args[0] if !args.empty? # PVars[self][#{v}] # end # EOS # end #end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
carats-0.3.0 | lib/carat-dev/vars/vars.rb |