App-Framework-Lite

 view release on metacpan or  search on metacpan

lib/App/Framework/Lite.pm  view on Meta::CPAN

	}
	close $in_fh ;

print "_module_str($module) - END\n" if $this->{'debug'};

	return $module_str ;
}


#---------------------------------------------------------------------
# Add a module to the HASH
#
# HASH is indexed by module name, each entry is a HASH:
#
# 'order'	=> number # order in which modules have been added
# 'content' => scalar # text of the module
#
sub _add_mod_lib
{
	my $this = shift ;
	my ($module, $libs_href) = @_ ;

	my $href ;
	if (exists($libs_href->{$module}))
	{
		# already in the list
		$href = $libs_href->{$module} ;
	}
	else
	{
		my $order = scalar(%$libs_href) + 1 ;
		$href = {
			'order'		=> $order,
			'content'	=> "",
		} ;
		$libs_href->{$module} = $href ;
	}

	return $href ;
}

#@NO-EMBED END


#---------------------------------------------------------------------
sub _setup_modules
{
	my $this = shift ;

	## Set up optional routines

	# Attempt to load Debug object
	if (_load_module('Debug::DumpObj'))
	{
		# Create local function
		*prt_data = sub {my $this = shift; Debug::DumpObj::prt_data(@_)} ;
	}
	else
	{
		# See if we've got Data Dummper
		if (_load_module('Data::Dumper'))
		{
			# Create local function
			*prt_data = sub {my $this = shift; print Dumper([@_])} ;
		}	
		else
		{
			# Create local function
			*prt_data = sub {my $this = shift; print @_, "\n"} ;
		}
	}

}


#---------------------------------------------------------------------
sub _load_module
{
	my ($mod) = @_ ;
	
	my $ok = 1 ;

	# see if we can load up the packages for thumbnail support
	if (eval "require $mod") 
	{
		$mod->import() ;
	}
	else 
	{
		# Can't load package
		$ok = 0 ;
	}
	return $ok ;
}



#----------------------------------------------------------------------------
#
#=item B<_register_fn()>
#
#Register a function provided as a subroutine in the caller package as an app method
#in this object.
#
#Will only set the field value if it's not already set.
#
#=cut
#
sub _register_fn 
{
	my $this = shift ;
	my ($function, $alias) = @_ ;
	
	$alias ||= $function ;
	my $field_name ="${alias}_fn" ; 

	$this->_register_var('CODE', $function, $field_name) unless $this->{$field_name} ;
}


#----------------------------------------------------------------------------



( run in 0.701 second using v1.01-cache-2.11-cpan-5b529ec07f3 )