+sub call_sub {
+ my $self = shift;
+ my $sub = shift;
+ return $self->$sub(@_);
+}
+
+sub call_sub_if {
+ my $self = shift;
+ my $sub = shift;
+ my $check = shift;
+
+ $check = $check->($self) if ref($check) eq 'CODE';
+
+ return $check ? $self->$sub(@_) : $self;
+}
+
+sub get_first_conflicting {
+ my ($self, @attributes) = @_;
+
+ my $primary_key = ($self->meta->primary_key)[0];
+ my @where = map { ($_ => $self->$_) } @attributes;
+
+ push @where, ("!$primary_key" => $self->$primary_key) if $self->$primary_key;
+
+ return $self->_get_manager_class->get_first(where => [ and => \@where ]);
+}
+
+# These three functions cannot sit in SL::DB::Object::Hooks because
+# mixins don't deal well with super classes (SUPER is the current
+# package's super class, not $self's).
+sub load {
+ my ($self, @args) = @_;
+
+ SL::DB::Object::Hooks::run_hooks($self, 'before_load');
+ my $result = $self->SUPER::load(@args);
+ SL::DB::Object::Hooks::run_hooks($self, 'after_load', $result);
+
+ return $result;