Version française
Home     About     Download     Resources     Contact us    
Browse thread
Passing class type as parameter?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jeremy Cowgar <jeremy@c...>
Subject: Passing class type as parameter?
Can I do something like:

class base_model = object(self)
   method from_array ary = ...
end ;;

class user = object(self)
   inherit base_model
   ...
end ;;

let finder sql class_type =
   query_database sql ;
   let res = new class_type in
     res#from_array res ;;

let users = finder "SELECT * FROM users" user in
   xxx yyy ;;

Ok. That is not working code, prob has syntax errors as well, but you  
get my idea. The problem I am having is passing the class to the  
generic finder method.

Thanks,

Jeremy