


=pod

=head1 NAME - M80Repository::RailsProject

RailsProject description; stub description please expand

=head1 EXAMPLE


    my $RailsProject = $RailsProject->new();   # stub example .... expand


# or in a m80 repository file
use M80Repository::RailsProject;
M80Repository::RailsProject->new(name => "MetadataObjectName",
			      interface => "Interface", # see $SYBASE/etc/freetds.conf
			      user => "scott",
			      password => "tiger")->dump;


=cut

# This file was automatically generated from RailsProject.pm.m80 by 
# bweinraub on li264-192 (Linux li264-192 2.6.35.4-x86_64-linode16 #1 SMP Mon Sep 20 16:03:34 UTC 2010 x86_64 GNU/Linux)
# DO NOT EDIT THIS FILE 


package M80Repository::RailsProject;

use Carp;
use Data::Dumper;
use Term::ANSIColor qw(:constants);
use strict;
sub Confess (@) {confess BOLD, RED, @_, RESET}
sub Warn (@) { warn YELLOW, BOLD, ON_BLACK, @_, RESET }

use File::Basename;

sub printmsg (@) { 
    my $date = localtime;
    print STDERR $date . ":" . basename($0) . ":($$): @_.\n" ;
}

sub printmsgn (@) { 
    my $date = localtime;
    print STDERR $date . ":" . basename($0) . ":($$): @_\n" ;
}


use base qw(M80Repository::Base);

=pod

=head1 INHERITANCE

M80Repository::RailsProject extends class M80Repository::Base ; refer to the documentation for that object for member variables and methods.

=cut

use fields qw( name standalone_port mongrel_ports external_address source_path description debug );

=pod

=head1 CONSTRUCTOR

=over 4

=item M80Repository::RailsProject->new()

initializes on object of type M80Repository::RailsProject

=back

=cut


# %_allSetters - an array of all setters for all members of the class
my %_allSetters = ();

my %_allMemberAttributes = ();

BEGIN {
# $_allMembers{_TYPE} = 1; # - WHAT IS THIS FOR?
$_allMemberAttributes{name} = {
          'name' => 'name',
          'description' => 'stub description of name'
        }
;
$_allSetters{name} = \&setName;
$_allMemberAttributes{standalone_port} = {
          'name' => 'standalone_port',
          'description' => 'not used in mongrep'
        }
;
$_allSetters{standalone_port} = \&setStandalone_port;
$_allMemberAttributes{mongrel_ports} = {
          'name' => 'mongrel_ports',
          'description' => 'not used in mongrep'
        }
;
$_allSetters{mongrel_ports} = \&setMongrel_ports;
$_allMemberAttributes{external_address} = {
          'name' => 'external_address',
          'description' => 'not used in mongrep'
        }
;
$_allSetters{external_address} = \&setExternal_address;
$_allMemberAttributes{source_path} = {
          'name' => 'source_path',
          'description' => 'not used in mongrep'
        }
;
$_allSetters{source_path} = \&setSource_path;
$_allMemberAttributes{description} = {
          'name' => 'description',
          'description' => 'not used in mongrep'
        }
;
$_allSetters{description} = \&setDescription;
$_allMemberAttributes{debug} = {
          'name' => 'debug',
          'description' => 'debug allows an object to specify its debugPrint level'
        }
;
$_allSetters{debug} = \&setDebug;


}

#
# TODO ... needs to merge in the parents attributes; the commented out block is close.
#
sub getReflectionAPI { 
#     my $this = shift; 
#     my %unified = (%{$this->SUPER::getReflectionAPI()}, %_allMemberAttributes);
#     \%unified;
    \%_allMemberAttributes;
}

#
# For some (currently) mysterious reason on perl 5.8.8 on the Linux kernel 2.6.18-8.1.14.el5 there
# is no data in the %_allMemberAttributes.  Therefore here is another way to get a list of member data
# out of the class.
#

sub getMembers {
    my $this = shift;
    my @ret = keys(%{$this});
    \@ret;
}
    
sub new {
    my M80Repository::RailsProject $this = shift;

    print STDERR "in M80Repository::RailsProject::new(" . join (",", @_) . ")\n" if $ENV{DEBUG};
    Confess "Missing the value for an argument (even nulls) on creation of M80Repository::RailsProject" if scalar @_ % 2 != 0;

    my %args = @_;

    unless (ref $this) {
	$this = fields::new($this);
    }

    #
    # This next block tries to set any of the values that you passed into this
    # constructor. You might have said new X( arg1 => 123, arg2 => 456); It is going
    # to take that and try to call setArg1(123), setArg2(123). I.e. it is going
    # to derive the setter for your named argument (by upper casing the first letter
    # of your argument name) and then if it finds that the object can call the
    # setter (i.e. it is defined in this class or any parent class) it will call it.
    #
    # If the setter cannot be found - then assume that this is a bad argument
    # that was passed to the function and die with that information.
    #
    foreach my $key (keys(%args)) {

        my $setterName = $key;                              # workspace for determining the name of the setter
        $setterName =~ s/^(\w)/uc($1)/e;                    # uc the first char of the argument name. I.e. arg1 => Arg1.
        $setterName = "set" . $setterName;                  # prepend "set" to the uppercased argument name.

        if (my $fn = $this->UNIVERSAL::can($setterName)) {  # test that the object can call this function
            $fn->($this,$args{$key});                       # and call it
        } else {                                            # else fail with an error. 
            Confess "Field named \"$key\" is not defined in object M80Repository::RailsProject. typo ?\n";
        }
    }



    #### __new is the magic "pre-constructor".  You can intercept a call to the parent
    #### constructor by defining a __new() procedure in your class.

    eval {M80Repository::RailsProject::__new($this,%args);};

    croak $@ if $@
	and $@ !~ /^Undefined subroutine.+?M80Repository::RailsProject::__new/;

    #### Now call the parent constructor, if any.

    eval {$this->SUPER::new(%args)};

    croak $@ if $@
	and $@ !~ /^Can\'t locate object method/;

    ####
    #### Typically this following contains your "real" constructor"
    #### so if you are debugging this next call my be a good candidate to step into.
    ####

    eval {M80Repository::RailsProject::_new($this,%args);};

    croak $@ if $@
	and $@ !~ /^Undefined subroutine.+?M80Repository::RailsProject::_new/;

    $this;
}

###  END GENERATED CODE

=pod

=head1 MEMBERS AND MEMBER ACCESS METHODS

=cut



=pod

=head2 name => "any string"

stub description of name

=cut

sub getName {

=pod

=head3 $RailsProject->getName ()


getter for member name

=cut

    my $this = shift;





    return $this->{name};
}
sub setName {

=pod

=head3 $RailsProject->setName (name => "any string")

 - name ("any string")		 : stub description of name

setter for member name

=cut

    my $this = shift;


    my $name = shift;



    $this->{name} = $name;
    return $name;
}



=pod

=head2 standalone_port => "any string"

not used in mongrep

=cut

sub getStandalone_port {

=pod

=head3 $RailsProject->getStandalone_port ()


getter for member standalone_port

=cut

    my $this = shift;





    return $this->{standalone_port};
}
sub setStandalone_port {

=pod

=head3 $RailsProject->setStandalone_port (standalone_port => "any string")

 - standalone_port ("any string")		 : not used in mongrep

setter for member standalone_port

=cut

    my $this = shift;


    my $standalone_port = shift;



    $this->{standalone_port} = $standalone_port;
    return $standalone_port;
}



=pod

=head2 mongrel_ports => "any string"

not used in mongrep

=cut

sub getMongrel_ports {

=pod

=head3 $RailsProject->getMongrel_ports ()


getter for member mongrel_ports

=cut

    my $this = shift;





    return $this->{mongrel_ports};
}
sub setMongrel_ports {

=pod

=head3 $RailsProject->setMongrel_ports (mongrel_ports => "any string")

 - mongrel_ports ("any string")		 : not used in mongrep

setter for member mongrel_ports

=cut

    my $this = shift;


    my $mongrel_ports = shift;



    $this->{mongrel_ports} = $mongrel_ports;
    return $mongrel_ports;
}



=pod

=head2 external_address => "any string"

not used in mongrep

=cut

sub getExternal_address {

=pod

=head3 $RailsProject->getExternal_address ()


getter for member external_address

=cut

    my $this = shift;





    return $this->{external_address};
}
sub setExternal_address {

=pod

=head3 $RailsProject->setExternal_address (external_address => "any string")

 - external_address ("any string")		 : not used in mongrep

setter for member external_address

=cut

    my $this = shift;


    my $external_address = shift;



    $this->{external_address} = $external_address;
    return $external_address;
}



=pod

=head2 source_path => "any string"

not used in mongrep

=cut

sub getSource_path {

=pod

=head3 $RailsProject->getSource_path ()


getter for member source_path

=cut

    my $this = shift;





    return $this->{source_path};
}
sub setSource_path {

=pod

=head3 $RailsProject->setSource_path (source_path => "any string")

 - source_path ("any string")		 : not used in mongrep

setter for member source_path

=cut

    my $this = shift;


    my $source_path = shift;



    $this->{source_path} = $source_path;
    return $source_path;
}



=pod

=head2 description => "any string"

not used in mongrep

=cut

sub getDescription {

=pod

=head3 $RailsProject->getDescription ()


getter for member description

=cut

    my $this = shift;





    return $this->{description};
}
sub setDescription {

=pod

=head3 $RailsProject->setDescription (description => "any string")

 - description ("any string")		 : not used in mongrep

setter for member description

=cut

    my $this = shift;


    my $description = shift;



    $this->{description} = $description;
    return $description;
}



=pod

=head2 debug => "any string"

debug allows an object to specify its debugPrint level

=cut

sub getDebug {

=pod

=head3 $RailsProject->getDebug ()


getter for member debug

=cut

    my $this = shift;





    return $this->{debug};
}
sub setDebug {

=pod

=head3 $RailsProject->setDebug (debug => "any string")

 - debug ("any string")		 : debug allows an object to specify its debugPrint level

setter for member debug

=cut

    my $this = shift;


    my $debug = shift;



    $this->{debug} = $debug;
    return $debug;
}



=pod

=head1 GENERALIZED OBJECT METHODS 

=cut



=pod

=over 4

=item _require (member1,member2,...,memberN)

will iterate over arguments and validate there is a non null value for each of the listed object members

=back

=cut


sub _require
{
    my $this = shift;
    map { 
	Confess "required member variable $_ not set" unless $this->getProperty($_);
    } (@_);
}

sub debugPrint { 
    my $this = shift;
    my $level = shift;
    Confess 'you\'ve called debugPrint - convert this call to $this->debugPrint()'
	unless ref($this);
    if ($this->{debug} >= $level || $main::debug >= $level) {
        my ($caller) = (caller(1))[3];
        $caller = "[$caller]:" if $caller;
        my $date = localtime;
        print STDERR $caller . $date . ":" . basename($0) . ":($$): @_.\n" ;
    }
}

sub debugPrint_s {   # static version of debug print
    my $level = shift;
    if ($main::debug >= $level) {
        my ($caller) = (caller(1))[3];
        $caller = "[$caller]:" if $caller;
        my $date = localtime;
        print STDERR $caller . $date . ":" . basename($0) . ":($$): @_.\n" ;
    }
}

use Carp;

sub docmdq (@) {    
    system(@_);

    my $rc;
    if ($? == -1) {
        $rc = -1; printmsg "failed to execute: $!";
	exit -1;
    }
    elsif ($? & 127) {
        $rc = $? & 127;
        printmsg "child process died with signal $rc, ", ($? & 128) ? 'with' : 'without', " coredump";
	exit $rc;
    }
    else {
        $rc = $? >> 8;
        if ($rc) {
            printmsg "child process exited with value $rc - Exiting!";
            exit $rc;
        }
    }
}

sub docmd (@) {    
    printmsg "@_" ;
    docmdq(@_);
}

1;

=pod

=head1 NOTES ON THIS DOCUMENTATION

In method signatures a * denotes a required option.

This file was automatically generated from RailsProject.pm.m80 by 
bweinraub on li264-192 (Linux li264-192 2.6.35.4-x86_64-linode16 #1 SMP Mon Sep 20 16:03:34 UTC 2010 x86_64 GNU/Linux)


=head1 OBJECT METHODS

=cut



sub _new {

=pod

=head3 $RailsProject->_new ()


callback constructor, do not call directly use new() instead

=cut

    my $this = shift;

    Confess "M80Repository::RailsProject->_new requires named arguments, or maybe a non-static method is being called in a static context " if scalar @_ && scalar @_ % 2 != 0;
    my %args = @_;



}


################################################################################

sub dump {
   
=pod

=head3 $RailsProject->dump ()


dump the output for the m80 repository

=cut

    my $this = shift;

    Confess "M80Repository::RailsProject->dump requires named arguments, or maybe a non-static method is being called in a static context " if scalar @_ && scalar @_ % 2 != 0;
    my %args = @_;



    do {
	my $ret = $this->SUPER::dump(@_) ; 
	
	if ($this->getStandalone_port()) {
	    $ret .= "\ndefine_variable([" . $this->getName . "_full_address],[" . $this->getExternal_address() . ":" . $this->getStandalone_port() . "])\n";
	} else {
	    $ret .= "\ndefine_variable([" . $this->getName . "_full_address],[" . $this->getExternal_address()  . "])\n";
	}

#	$ret .= "\ndefine_variable([" . $this->getName . "_type],[sqlserver])\n";
	$ret;
    };
}
