Sha256: e72ca0c27022d5a93abe807394eb24698ae64d59d9ed79b2725e1395c252b70d
Contents?: true
Size: 1010 Bytes
Versions: 229
Compression:
Stored size: 1010 Bytes
Contents
# RGen Framework # (c) Martin Thiede, 2006 require 'rgen/metamodel_builder' module RGen module Util 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 end
Version data entries
229 entries across 229 versions & 3 rubygems