Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Refactoring lazy initialization for model metadata #652

merged 1 commit into from Sep 21, 2012


None yet
2 participants

jails commented Sep 21, 2012

Hi nate, I saw you have already implemented the lazy initialization for model metadata, sorry for the delay.
In this PR you will find my acutal "state" for this subject (from your implementation).
Using $_meta in closures is imo not safe since $_meta may contains in the same time initialized and not yet initialized metadata. Since the initialization is done lazily the order of initialization may produce different results. I also updated the autoConfig and added some tests.

Example of use :

    'initializers' => array(
        'source' => function($self) {
            return 'custom_' . Inflector::underscore($self::meta('name'));
        'name' => function($self) {
            return Inflector::singularize(basename(str_replace('\\', '/', $self)));

nateabele commented Sep 21, 2012


@nateabele nateabele added a commit that referenced this pull request Sep 21, 2012

@nateabele nateabele Merge pull request #652 from jails/pr44
Refactoring lazy initialization for model metadata

@nateabele nateabele merged commit f2b556e into UnionOfRAD:data Sep 21, 2012

1 check passed

default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment