Catalyst-ControllerPerContext

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

# This file documents the revision history for Perl extension CatalystX-ControllerPerContext.

0.008 - 10 October 2024
  - Tweaks to some of the experimental base object stuff

0.007 - 02 January 2024
  - No changes to CatalystX::ControllerPerContext.
  - Catalyst::ControllerRole::View now supports the concept of view fragments.
    This obviously only works if your view supports it.  Right now only the
    experiemental view that ships with Valiant does.
  - CatalystX::Moose an experimental extention to Moose that adds support for
    MethodAttributes out of the box as well as allows you to initialize component
    arguments from stash or context values.   No docs because if you aren't good
    enough to figure it out from the codeyou probably shouldn't be using it at this
    stage.  Ping me if you want to know more.

0.006 - 26 August 2023
  - Some example roles that are probably dangerous.  If you cut yourself

lib/Catalyst/ControllerRole/URI.pm  view on Meta::CPAN

  my $path = join('/', '', @display_parts) || '/';
  $path = "${extra} ${path}" if $extra;

  return $path, \@path_args;
}

sub _normalize_uri_args {
  my $self = shift;
  my $parts_proto = shift if $_[0] && ((ref($_[0]) eq 'ARRAY') || ( blessed($_[0]) ));
  my $query = shift if $_[0] && (ref($_[0]) eq 'HASH');
  my $fragment = shift if $_[0] && (ref($_[0]) eq 'SCALAR');

  my $c = $self->ctx;
  my @parts = ();

  # If parts are passed in then use them. If just one and its a blessed object
  # then use its id. If an arrayref then use the ids of the objects.
  if(blessed $parts_proto) {
    push @parts, $parts_proto->id;
  } elsif(ref($parts_proto) eq 'ARRAY') {
    my @part_ids = map { blessed $_ ? $_->id : $_ } @$parts_proto;
    push @parts, @part_ids;
  }

  my @return_args = (\@parts);
  push @return_args, $query if $query;
  push @return_args, $fragment if $fragment;

  return @return_args;
}

1;

=head1 NAME
 
Catalyst::ControllerRole::URI - Inject local URI helpers

lib/Catalyst/ControllerRole/View.pm  view on Meta::CPAN

);

sub view {
  my ($self, @args) = @_;
  return $self->ctx->stash->{current_view_instance} if exists($self->ctx->stash->{current_view_instance}) && !@args;
  return $self->view_for($self->ctx->action, @args);
}

sub view_at {
  my ($self, $view_name_proto, @args) = @_;
  my ($view_name, $view_fragment) = split(/\./, $view_name_proto);
  push @args, view_fragment => $view_fragment if $view_fragment;

  $view_name = "@{[$self->path_prefix]}/$view_name" if $self->path_prefix;
  my $namepart = String::CamelCase::camelize($view_name);
  $namepart =~s/\//::/g;

  my $view = $self->_build_view_name($namepart);
  $self->ctx->log->debug("Initializing View: $view") if $self->ctx->debug;
  return $self->ctx->view($view, @args);
}

sub view_for {
  my ($self, $proto, @args) = @_;
  my ($action_proto, $view_fragment) = Scalar::Util::blessed($proto)
    ? ($proto, undef)
    : split(/\./, $proto);
  
  push @args, view_fragment => $view_fragment if $view_fragment;

  my $action = Scalar::Util::blessed($action_proto)
    ? $action_proto
    : $self->action_for($action_proto);

  return $self->view_at($proto, @args) unless $action; # Not sure if this is right

  my $action_namepart = $self->_action_namepart_from_action($action);
  my $view = $self->_build_view_name($action_namepart);

lib/CatalystX/Moose.pm  view on Meta::CPAN

    if(my $writer_name = $attr->get_write_method) {
      $class->add_before_method_modifier($writer_name, sub {
        my ($self, $value) = @_;
        return unless defined $value;
        $self->ctx->stash->{$attr->to_key} = $value;
      });
    }
  }


  # This seems like a fragile hack, if anyone has a better way to
  # trigger the lazy builder, please let me know.

  if(my $reader_name = $attr->get_read_method) {
    my $sub = sub {
      my ($self) = @_;
      $self->$reader_name;
    };
    $class->can('BUILD') ?
      $class->add_after_method_modifier('BUILD', $sub) :
        $class->add_method('BUILD', $sub);



( run in 2.239 seconds using v1.01-cache-2.11-cpan-364913b4093 )