lib/class_utils.rb
  Returns a valid database-class name, nil if the class does not exists
Returns a valid database-class name, nil if the class does not exists
Returns a valid database - class name nil if the class does not exists
def allocate_class_in_ruby db_classname, &b
    unless ActiveOrient.database_classes[ db_classname ].is_a? Class
      s = get_db_superclass( db_classname )
      superclass =  if s.present? 
		      allocate_class_in_ruby( s, &b ) 
		    else
		      ActiveOrient::Model
		    end
      if superclass.nil?
	ActiveOrient.database_classes[ db_classname ] = "Superclass model file missing"
	return
      end
      reduced_classname =  superclass.namespace_prefix.present? ? db_classname.split( superclass.namespace_prefix ).last :  db_classname
      classname =  superclass.naming_convention(  reduced_classname )
      the_class = if !( ActiveOrient::Model.namespace.send :const_defined?, classname, false )
		    ActiveOrient::Model.namespace.send( :const_set, classname, Class.new( superclass ) )
		  elsif ActiveOrient::Model.namespace.send( :const_get, classname).ancestors.include?( ActiveOrient::Model )
		    ActiveOrient::Model.namespace.send( :const_get, classname)
		  else
		    t= ActiveOrient::Model.send :const_set, classname, Class.new( superclass )
		    logger.warn{ "Unable to allocate class #{classname} in Namespace #{ActiveOrient::Model.namespace}"}
		    logger.warn{ "Allocation took place with namespace ActiveOrient::Model" }
		    t
		  end
      the_class.ref_name = db_classname
      keep_the_dataset = block_given? ? yield( the_class ) : true
      if keep_the_dataset 
	ActiveOrient.database_classes[db_classname] = the_class 
	the_class.ref_name =  db_classname
	the_class 
      else
	unless ["E","V"].include? classname  
	  base_classname =  the_class.to_s.split("::").last.to_sym
	  if ActiveOrient::Model.namespace.send( :const_defined? , classname)
	    ActiveOrient::Model.namespace.send( :remove_const, classname )
	  else
	    ActiveOrient::Model.send( :remove_const, classname)
	  end
	end
	nil  
      end
    else
      ActiveOrient.database_classes[db_classname] 
    end
  end
def allocate_class_in_ruby db_classname , & b unless ActiveOrient . database_classes [ db_classname ] . is_a? Class s = get_db_superclass ( db_classname ) superclass = if s . present? allocate_class_in_ruby ( s , & b ) else ActiveOrient :: Model end if superclass . nil? ActiveOrient . database_classes [ db_classname ] = "Superclass model file missing" return end reduced_classname = superclass . namespace_prefix . present? ? db_classname . split ( superclass . namespace_prefix ) . last : db_classname classname = superclass . naming_convention ( reduced_classname ) the_class = if ! ( ActiveOrient :: Model . namespace . send :const_defined? , classname , false ) ActiveOrient :: Model . namespace . send ( :const_set , classname , Class . new ( superclass ) ) elsif ActiveOrient :: Model . namespace . send ( :const_get , classname ) . ancestors . include? ( ActiveOrient :: Model ) ActiveOrient :: Model . namespace . send ( :const_get , classname ) else t = ActiveOrient :: Model . send :const_set , classname , Class . new ( superclass ) logger . warn { "Unable to allocate class #{classname} in Namespace #{ActiveOrient::Model.namespace}" } logger . warn { "Allocation took place with namespace ActiveOrient::Model" } t end the_class . ref_name = db_classname keep_the_dataset = block_given? ? yield ( the_class ) : true if keep_the_dataset ActiveOrient . database_classes [ db_classname ] = the_class the_class . ref_name = db_classname the_class else unless [ "E" , "V" ] . include? classname base_classname = the_class . to_s . split ( "::" ) . last . to_sym if ActiveOrient :: Model . namespace . send ( :const_defined? , classname ) ActiveOrient :: Model . namespace . send ( :remove_const , classname ) else ActiveOrient :: Model . send ( :remove_const , classname ) end end nil end else ActiveOrient . database_classes [ db_classname ] end end
Returns a valid database-class name, nil if the class does not exists
Returns a valid database - class name nil if the class does not exists
# retrieve the superclass recursively # superclass is nil, if allocate_class_in_ruby is recursivley # called and the superclass was not established #  return the generated class # never remove Base-Classes! # return-value # return previosly allocated ruby-class
db_classname
<not_specific>
b
<not_specific>