« blib/lib/UR/BoolExpr/Template/PropertyComparison/NotEquals.pm
↑ Summary
blib/lib/UR/DeletedRef.pm »
| 1 | |||
| 2 | package UR::DataSource::Code; | ||
| 3 | |||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | require UR; | ||
| 7 | our $VERSION = "0.46"; # UR $VERSION; | ||
| 8 | use File::Copy qw//; | ||
| 9 | ##- use UR; | ||
| 10 | |||
| 11 | UR::Object::Type->define( | ||
| 12 | class_name => 'UR::DataSource::Code', | ||
| 13 | is => ['UR::DataSource::SQLite'], | ||
| 14 | ); | ||
| 15 | |||
| 16 | sub server { | ||
| 17 | my $self = shift->_singleton_object(); | ||
| 18 | my $path = $self->__meta__->module_path; | ||
| 19 | $path =~ s/\.pm$/.db/ or Carp::confess("Bad module path for resolving server!"); | ||
| 20 | unless (-e $path) { | ||
| 21 | # initialize a new database from the one in the base class | ||
| 22 | # should this be moved to connect time? | ||
| 23 | my $template_database_file = UR::DataSource::Code->server(); | ||
| 24 | if ($self->class eq __PACKAGE__) { | ||
| 25 | Carp::confess("Missing template database file: $path!"); | ||
| 26 | } | ||
| 27 | unless (-e $template_database_file) { | ||
| 28 | Carp::confess("Missing template database file: $path! Cannot initialize database for " . $self->class); | ||
| 29 | } | ||
| 30 | unless(File::Copy::copy($template_database_file,$path)) { | ||
| 31 | Carp::confess("Error copying $path to $template_database_file to initialize database!"); | ||
| 32 | } | ||
| 33 | unless(-e $path) { | ||
| 34 | Carp::confess("File $path not found after copy from $template_database_file. Cannot initialize database!"); | ||
| 35 | } | ||
| 36 | } | ||
| 37 | return $path; | ||
| 38 | } | ||
| 39 | |||
| 40 | sub resolve_class_name_for_table_name_fixups { | ||
| 41 | my $self = shift->_singleton_object; | ||
| 42 | print "fixup @_"; | ||
| 43 | return $self->class . "::", @_; | ||
| 44 | } | ||
| 45 | |||
| 46 | 1; |