DustyDB::Meta::Instance - helper for auto-vivifying model links on demand


DustyDB documentation Contained in the DustyDB distribution.

Index


Code Index:

NAME

Top

DustyDB::Meta::Instance - helper for auto-vivifying model links on demand

VERSION

Top

version 0.06

DESCRIPTION

Top

Do not use this class directly. Just by using DustyDB::Object, you have done everything you need to work with this class.

METHODS

Top

get_slot_value

This method has been enhanced to perform deferred loading of FK objects.

inline_get_slot_value

This method has been enhanced to performed deferred loading of FK object in inline accessor code.


DustyDB documentation Contained in the DustyDB distribution.
package DustyDB::Meta::Instance;
our $VERSION = '0.06';

use Moose::Role;

use Scalar::Util qw( reftype );

override get_slot_value => sub {
    my ($instance, $struct, $name) = @_;
    my $value = super($struct, $name);

    if (blessed $value and blessed($value)->isa('DustyDB::FakeRecord')) {
        $value = $value->vivify;
        $instance->set_slot_value($struct, $name, $value);
    }

    return $value;
};

override inline_get_slot_value => sub {
    my ($instance, $struct, $name) = @_;
    my $super = super($struct, $name);

    return q#do {
                my $value = # . $super . q#;

                if (Scalar::Util::blessed($value) and Scalar::Util::blessed($value)->isa('DustyDB::FakeRecord')) {
                        $value = $value->vivify;
                }

                $value;
        }#;
};

1;