Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 0b89d2ca

Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt

  • ID 0b89d2ca35a0e0d9d3add90b1289e27bfc87c83c
  • Vorgänger 2a201b35
  • Nachfolger 67ca0f93

Funktion get_first_conflicting() im Model-Basisklasse

Unterschiede anzeigen:

SL/DB/Object.pm
96 96
  return $check ? $self->$sub(@_) : $self;
97 97
}
98 98

  
99
sub get_first_conflicting {
100
  my ($self, @attributes) = @_;
101

  
102
  my $primary_key         = ($self->meta->primary_key)[0];
103
  my @where               = map { ($_ => $self->$_) } @attributes;
104

  
105
  push @where, ("!$primary_key" => $self->$primary_key) if $self->$primary_key;
106

  
107
  return $self->_get_manager_class->get_first(where => [ and => \@where ]);
108
}
109

  
99 110
# These three functions cannot sit in SL::DB::Object::Hooks because
100 111
# mixins don't deal well with super classes (SUPER is the current
101 112
# package's super class, not $self's).
......
224 235
Returns the sub's result if the check is positive and C<$self>
225 236
otherwise.
226 237

  
238
=item C<get_first_conflicting @attributes>
239

  
240
Returns the first object for which all properties listed in
241
C<@attributes> equal those in C<$self> but which is not C<$self>. Can
242
be used to check whether or not an object's columns are unique before
243
saving or during validation.
244

  
227 245
=back
228 246

  
229 247
=head1 AUTHOR

Auch abrufbar als: Unified diff