aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Reaction/InterfaceModel/Reflector/DBIC.pm
diff options
context:
space:
mode:
authormatthewt <matthewt@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2008-03-05 19:15:30 +0000
committermatthewt <matthewt@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2008-03-05 19:15:30 +0000
commit4949e0ee7a1162bca838822095e6cd2da527e2d2 (patch)
tree6ca87a2bb118f1abd37ffd04e91f058c9ec1e3b8 /lib/Reaction/InterfaceModel/Reflector/DBIC.pm
parent335754e0e6a978284ab11afcc9c3d9da237df52c (diff)
downloadreaction-4949e0ee7a1162bca838822095e6cd2da527e2d2.tar.gz
reaction-4949e0ee7a1162bca838822095e6cd2da527e2d2.zip
rewrite IM predicates
Diffstat (limited to 'lib/Reaction/InterfaceModel/Reflector/DBIC.pm')
-rw-r--r--lib/Reaction/InterfaceModel/Reflector/DBIC.pm12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/Reaction/InterfaceModel/Reflector/DBIC.pm b/lib/Reaction/InterfaceModel/Reflector/DBIC.pm
index 120ddb1..2c34cdf 100644
--- a/lib/Reaction/InterfaceModel/Reflector/DBIC.pm
+++ b/lib/Reaction/InterfaceModel/Reflector/DBIC.pm
@@ -676,7 +676,10 @@ class DBIC, which {
#default options. lazy build but no outsider method
my %attr_opts = ( is => 'ro', lazy => 1, required => 1,
clearer => "_clear_${attr_name}",
- predicate => "has_${attr_name}",
+ predicate => {
+ "has_${attr_name}" =>
+ sub { defined(shift->$dm_name->$attr_name) }
+ },
domain_model => $dm_name,
orig_attr_name => $attr_name,
);
@@ -706,8 +709,11 @@ class DBIC, which {
#type constraint is the foreign IM object, default inflates it
$attr_opts{isa} = $self->class_name_from_source_name($parent_class, $rel_moniker);
$attr_opts{default} = sub {
- shift->$dm_name
- ->find_related($attr_name, {},{result_class => $attr_opts{isa}});
+ if (defined(my $o = shift->$dm_name->$attr_name)) {
+ return $attr_opts{isa}->inflate_result($o->result_source, { $o->get_columns });
+ }
+ return undef;
+ #->find_related($attr_name, {},{result_class => $attr_opts{isa}});
};
}
} elsif( $constraint_is_ArrayRef && $attr_name =~ m/^(.*)_list$/ ) {