[Bast-commits] r8742 - in DBIx-Class-Journal/1.000/trunk/lib/DBIx/Class: . Schema Schema/Journal

frew at dev.catalyst.perl.org frew at dev.catalyst.perl.org
Thu Feb 18 16:31:16 GMT 2010


Author: frew
Date: 2010-02-18 16:31:15 +0000 (Thu, 18 Feb 2010)
New Revision: 8742

Modified:
   DBIx-Class-Journal/1.000/trunk/lib/DBIx/Class/Journal.pm
   DBIx-Class-Journal/1.000/trunk/lib/DBIx/Class/Schema/Journal.pm
   DBIx-Class-Journal/1.000/trunk/lib/DBIx/Class/Schema/Journal/DB.pm
Log:
basic code cleanup

Modified: DBIx-Class-Journal/1.000/trunk/lib/DBIx/Class/Journal.pm
===================================================================
--- DBIx-Class-Journal/1.000/trunk/lib/DBIx/Class/Journal.pm	2010-02-18 16:14:38 UTC (rev 8741)
+++ DBIx-Class-Journal/1.000/trunk/lib/DBIx/Class/Journal.pm	2010-02-18 16:31:15 UTC (rev 8742)
@@ -15,21 +15,19 @@
     $self->result_source->schema->_journal_schema;
 }
 
-sub insert
-{
+sub insert {
     my ($self, @args) = @_;
 
-    return if($self->in_storage);
+    return if $self->in_storage;
 
     my $res = $self->next::method(@args);
 
-    $self->journal_log_insert();
+    $self->journal_log_insert;
 
     return $res;
 }
 
-sub journal_log_insert
-{
+sub journal_log_insert {
     my ($self) = @_;
 
     if ( $self->in_storage ) {
@@ -42,15 +40,13 @@
 
 ## On delete, update delete_id of AuditLog
 
-sub delete
-{
-    my ($self, @rest) = @_;
-    $self->next::method(@rest);
-    $self->journal_log_delete(@rest);
+sub delete {
+    my $self = shift;
+    $self->next::method(@_);
+    $self->journal_log_delete(@_);
 }
 
-sub journal_log_delete
-{
+sub journal_log_delete {
     my ($self) = @_;
 
     unless ($self->in_storage) {
@@ -61,19 +57,16 @@
 
 ## On update, copy previous row's contents to AuditHistory
 
-sub update
-{
-    my ($self, $upd, @rest) = @_;
-    $self->journal_log_update($upd, @rest);
-    $self->next::method($upd, @rest);
+sub update {
+    my $self = shift;
+    $self->journal_log_update(@_);
+    $self->next::method(@_);
 }
 
-sub journal_log_update
-{
-    my ($self, $upd, @rest) = @_;
+sub journal_log_update {
+    my $self = shift;
 
-    if($self->in_storage)
-    {
+    if($self->in_storage) {
         my $j = $self->_journal_schema;
 
         my $change = $j->journal_create_change;

Modified: DBIx-Class-Journal/1.000/trunk/lib/DBIx/Class/Schema/Journal/DB.pm
===================================================================
--- DBIx-Class-Journal/1.000/trunk/lib/DBIx/Class/Schema/Journal/DB.pm	2010-02-18 16:14:38 UTC (rev 8741)
+++ DBIx-Class-Journal/1.000/trunk/lib/DBIx/Class/Schema/Journal/DB.pm	2010-02-18 16:31:15 UTC (rev 8742)
@@ -22,11 +22,15 @@
 sub current_changeset {
     my ( $self, @args ) = @_;
 
-    $self->throw_exception("setting current_changeset is not supported, use txn_do to create a new changeset") if @args;
+    $self->throw_exception(
+       'setting current_changeset is not supported, use txn_do to create a new changeset'
+    ) if @args;
 
     my $id = $self->_current_changeset;
 
-    $self->throw_exception("Can't call current_changeset outside of a transaction") unless $id;
+    $self->throw_exception(
+       q{Can't call current_changeset outside of a transaction}
+    ) unless $id;
 
     return $id;
 }
@@ -38,12 +42,10 @@
 
     delete $changesetdata{parent_id} unless $self->nested_changesets;
 
-    if( defined( my $user = $self->current_user() ) )
-    {
+    if( defined( my $user = $self->current_user() ) ) {
         $changesetdata{user_id} = $user;
     }
-    if( defined( my $session = $self->current_session() ) )
-    {
+    if( defined( my $session = $self->current_session() ) ) {
         $changesetdata{session_id} = $session;
     }
 
@@ -55,11 +57,12 @@
 
 sub journal_create_change {
     my $self = shift;
-    $self->resultset("ChangeLog")->create({ changeset_id => $self->current_changeset });
+    $self->resultset('ChangeLog')->create({
+       changeset_id => $self->current_changeset
+    });
 }
 
-sub journal_update_or_create_log_entry
-{
+sub journal_update_or_create_log_entry {
     my ($self, $row, @cols) = @_;
 
     my $s_name = $row->result_source->source_name;
@@ -69,8 +72,7 @@
     $self->resultset("${s_name}AuditLog")->update_or_create({ @cols, %id });
 }
 
-sub journal_record_in_history
-{
+sub journal_record_in_history {
     my ($self, $row, @cols) = @_;
 
     my $s_name = $row->result_source->source_name;

Modified: DBIx-Class-Journal/1.000/trunk/lib/DBIx/Class/Schema/Journal.pm
===================================================================
--- DBIx-Class-Journal/1.000/trunk/lib/DBIx/Class/Schema/Journal.pm	2010-02-18 16:14:38 UTC (rev 8741)
+++ DBIx-Class-Journal/1.000/trunk/lib/DBIx/Class/Schema/Journal.pm	2010-02-18 16:31:15 UTC (rev 8742)
@@ -21,32 +21,25 @@
 use warnings;
 
 
-sub _journal_schema_prototype
-{
+sub _journal_schema_prototype {
     my $self = shift;
-    if (my $proto = $self->__journal_schema_prototype)
-    {
+    if (my $proto = $self->__journal_schema_prototype) {
           return $proto;
     }
     my $c = blessed($self)||$self;
     my $journal_schema_class = "${c}::_JOURNAL";
     Class::C3::Componentised->inject_base($journal_schema_class, 'DBIx::Class::Schema::Journal::DB');
-    my $proto = $self->__journal_schema_prototype
-    (
-        $journal_schema_class->compose_namespace
-        (
-            $c.'::Journal'
-        )
+    my $proto = $self->__journal_schema_prototype (
+        $journal_schema_class->compose_namespace( $c.'::Journal')
     );
     my $comp = $self->journal_component || "Journal";
 
     ## Create auditlog+history per table
     my %j_sources = map { $_ => 1 } $self->journal_sources
-                                      ? @{$self->journal_sources}
-                                      : $self->sources;
+       ? @{$self->journal_sources}
+       : $self->sources;
 
-    foreach my $s_name ($self->sources)
-    {
+    foreach my $s_name ($self->sources) {
         next unless($j_sources{$s_name});
         $self->create_journal_for($s_name => $proto);
         $self->class($s_name)->load_components($comp);
@@ -54,19 +47,15 @@
     return $proto;
 }
 
-sub connection
-{
+sub connection {
     my $self = shift;
     my $schema = $self->next::method(@_);
 
     my $journal_schema = (ref $self||$self)->_journal_schema_prototype->clone;
 
-    if($self->journal_connection)
-    {
-        if($self->journal_storage_type)
-        {
-            $journal_schema->storage_type($self->journal_storage_type);
-        }
+    if($self->journal_connection) {
+        $journal_schema->storage_type($self->journal_storage_type)
+            if $self->journal_storage_type;
         $journal_schema->connection(@{ $self->journal_connection });
     } else {
         $journal_schema->storage( $schema->storage );
@@ -77,15 +66,14 @@
 
     if ( $self->journal_nested_changesets ) {
         $self->_journal_schema->nested_changesets(1);
-        die "FIXME nested changeset schema not yet supported... add parent_id to ChangeSet here";
+        die 'FIXME nested changeset schema not yet supported... add parent_id to ChangeSet here';
     }
 
     $self->journal_schema_deploy()
         if $self->journal_deploy_on_connect;
 
     ## Set up relationship between changeset->user_id and this schema's user
-    if(!@{$self->journal_user || []})
-    {
+    if(!@{$self->journal_user || []}) {
         #warn "No Journal User set!"; # no need to warn, user_id is useful even without a rel
         return $schema;
     }
@@ -96,24 +84,21 @@
     return $schema;
 }
 
-sub deploy
-{
-    my ( $self, $sqlt_args, @args ) = @_;
+sub deploy {
+    my $self = shift;
 
-    $self->next::method($sqlt_args, @args);
+    $self->next::method(@_);
 
-    $self->journal_schema_deploy($sqlt_args, @args);
+    $self->journal_schema_deploy(@_);
 }
 
-sub journal_schema_deploy
-{
-    my ( $self, $sqlt_args, @args ) = @_;
+sub journal_schema_deploy {
+    my $self = shift;
 
-    $self->_journal_schema->deploy( $sqlt_args, @args );
+    $self->_journal_schema->deploy(@_);
 }
 
-sub create_journal_for
-{
+sub create_journal_for {
     my ($self, $s_name, $journal_schema) = @_;
 
     my $source = $self->source($s_name);
@@ -128,15 +113,12 @@
 
         $journal_schema->register_class($audit_source, $class);
 
-        if ($self->journal_copy_sources)
-        {
-            $self->register_class($audit_source, $class);
-        }
+        $self->register_class($audit_source, $class)
+            if $self->journal_copy_sources;
     }
 }
 
-sub txn_do
-{
+sub txn_do {
     my ($self, $user_code, @args) = @_;
 
     my $jschema = $self->_journal_schema;
@@ -144,8 +126,7 @@
     my $code = $user_code;
 
     my $current_changeset = $jschema->_current_changeset;
-    if ( !$current_changeset || $self->journal_nested_changesets )
-    {
+    if ( !$current_changeset || $self->journal_nested_changesets ) {
         my $current_changeset_ref = $jschema->_current_changeset_container;
 
         unless ( $current_changeset_ref ) {
@@ -171,20 +152,20 @@
     return $self->next::method($code, @args);
 }
 
-sub changeset_user
-{
+sub changeset_user {
     my ($self, $userid) = @_;
 
-    return $self->_journal_schema->current_user() if(@_ == 1);
+    return $self->_journal_schema->current_user()
+       if @_ == 1;
 
     $self->_journal_schema->current_user($userid);
 }
 
-sub changeset_session
-{
+sub changeset_session {
     my ($self, $sessionid) = @_;
 
-    return $self->_journal_schema->current_session() if(@_ == 1);
+    return $self->_journal_schema->current_session()
+       if @_ == 1;
 
     $self->_journal_schema->current_session($sessionid);
 }




More information about the Bast-commits mailing list