Skip to content

Instantly share code, notes, and snippets.

@slaskis
Created September 27, 2009 16:41
Show Gist options
  • Save slaskis/194875 to your computer and use it in GitHub Desktop.
Save slaskis/194875 to your computer and use it in GitHub Desktop.
public function call( scope , func ) {
var obj = Type.createEmptyInstance( Home );
//var obj = Type.createInstance( Home , [] );
trace( Type.getInstanceFields( obj ) );
if( !Reflect.hasField( obj , func ) )
throw obj + " does not contain " + func;
var method = Reflect.field( obj , func );
if( !Reflect.isFunction( method ) )
throw func + " is not a method of " + obj;
var ret = Reflect.callMethod( obj , method , [] );
trace( "Returned: " + ret );
return ret;
}
call( Home , "index" );
class Home extends Controller {
public function index() {
return "view/Home.ehx";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment