home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / perl / Subcomponent.pm < prev    next >
Encoding:
Perl POD Document  |  2003-11-12  |  2.1 KB  |  84 lines

  1. # Copyright (c) 1998-2003 by Jonathan Swartz. All rights reserved.
  2. # This program is free software; you can redistribute it and/or modify
  3. # it under the same terms as Perl itself.
  4.  
  5. package HTML::Mason::Component::Subcomponent;
  6.  
  7. use strict;
  8.  
  9. use HTML::Mason::Component;
  10.  
  11. use vars qw(@ISA);
  12.  
  13. @ISA = qw(HTML::Mason::Component);
  14.  
  15. use HTML::Mason::MethodMaker ( read_only => [ qw( comp_id is_method name owner path ) ] );
  16.  
  17. #
  18. # Assign parent, name, and is_method flag when owner component is created.
  19. #
  20. sub assign_subcomponent_properties {
  21.     my $self = shift;
  22.     ($self->{owner}, $self->{name}, $self->{is_method}) = @_;
  23. }
  24.  
  25. #
  26. # Override path that would be set by parent's version of method.
  27. #
  28. sub assign_runtime_properties {
  29.     my ($self, $interp, $source) = @_;
  30.     $self->SUPER::assign_runtime_properties($interp, $source);
  31.     $self->{comp_id} = sprintf("[%s '%s' of %s]", $self->{is_method} ? 'method' : 'subcomponent',
  32.                    $self->name, $self->owner->comp_id);
  33.     $self->{path} = $self->owner->path . ":" . $self->name;
  34. }
  35.  
  36. sub cache_file { return $_[0]->owner->cache_file }
  37. sub load_time { return $_[0]->owner->load_time }
  38. sub compiler_id { return $_[0]->owner->compilation_params }
  39. sub dir_path { return $_[0]->owner->dir_path }
  40. sub is_subcomp { 1 }
  41. sub object_file { return $_[0]->owner->object_file }
  42. sub parent { return $_[0]->owner->parent }
  43. sub persistent { return $_[0]->owner->persistent }
  44. sub title { return $_[0]->owner->title . ":" . $_[0]->name }
  45.  
  46. 1;
  47.  
  48. __END__
  49.  
  50. =head1 NAME
  51.  
  52. HTML::Mason::Component::Subcomponent - Mason Subcomponent Class
  53.  
  54. =head1 DESCRIPTION
  55.  
  56. This is a subclass of
  57. L<HTML::Mason::Component|HTML::Mason::Component>. Mason uses it to
  58. implement both subcomponents (defined by C<< <%def> >>) and methods (defined
  59. by C<< <%method> >>).
  60.  
  61. A subcomponent gets most of its properties from its owner.
  62.  
  63. =head1 METHODS
  64.  
  65. =over 4
  66.  
  67. =item is_method
  68.  
  69. Returns 1 if this is a method (declared by C<< <%method> >>), 0 if it is a
  70. subcomponent (defined by c<< <%def> >>).
  71.  
  72. =item owner
  73.  
  74. Return the component object that this subcomponent or method was
  75. defined within.
  76.  
  77. =back
  78.  
  79. =head1 SEE ALSO
  80.  
  81. L<HTML::Mason::Component|HTML::Mason::Component>
  82.  
  83. =cut
  84.