Sha256: e51e78a92087fa1b88c5ddc1248869e1e13bd1728e5b3802992e466559040442
Contents?: true
Size: 984 Bytes
Versions: 14
Compression:
Stored size: 984 Bytes
Contents
# RGen Framework # (c) Martin Thiede, 2006 require 'rgen/metamodel_builder' module RGen class Base extend MetamodelBuilder def initialize(env=nil) env << self if env end end class AutoCreatedClass < Base def method_missing(m,*args) return super unless self.class.parent.accEnabled if m.to_s =~ /(.*)=$/ self.class.has_one($1) send(m,args[0]) elsif args.size == 0 self.class.has_many(m) send(m) end end end # will be "extended" to the auto created class module ParentAccess def parent=(p) @parent = p end def parent @parent end end module AutoClassCreator attr_reader :accEnabled def const_missing(className) return super unless @accEnabled module_eval("class "+className.to_s+" < RGen::AutoCreatedClass; end") c = const_get(className) c.extend(ParentAccess) c.parent = self c end def enableACC @accEnabled = true end def disableACC @accEnabled = false end end end
Version data entries
14 entries across 14 versions & 1 rubygems