File: BaseResultSet.pm

package info (click to toggle)
libdbix-class-perl 0.082844-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,320 kB
  • sloc: perl: 27,215; sql: 322; sh: 29; makefile: 16
file content (52 lines) | stat: -rw-r--r-- 1,155 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package #hide from pause
  DBICTest::BaseResultSet;

use strict;
use warnings;

BEGIN {
  my @subclassing = qw(DBICTest::Base DBIx::Class::ResultSet);

  if( ! $ENV{DBICTEST_MOOIFIED_RESULTSETS} ) {
    # plain old vanilla base.pm
    require base;
    base->import(@subclassing);
  }
  else {
    # do a string eval to make sure Moo doesn't get confused
    require Carp;
    eval <<'EOM'


use Moo;
extends @subclassing;

# ::RS::new() expects my ($class, $rsrc, $args) = @_
# Moo(se) expects a single hashref ( $args ), and makes it mandatory
#
# Ensure that unless we are called from a test - DBIC always fills it in
sub BUILDARGS {
  if(
    ! defined $_[2]
      and
    # not a direct call from a test file
    (caller(1))[1] !~ m{ (?: ^ | \/ | \\ ) t [\/\\] .+ \.t $ }x
  ) {
    $Carp::CarpLevel += 2;
    Carp::confess( "...::ResultSet->new() called without supplying an ( empty ) hashref as argument: this fails with Moo(se) and incomplete BUILDARGS. Problematic stacktrace begins" );
  }

  $_[2] || {};
}


EOM

  }
}

sub all_hri {
  return [ shift->search ({}, { result_class => 'DBIx::Class::ResultClass::HashRefInflator' })->all ];
}

1;