Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • You could nearly call that Class::Inner and have it work like Java's inner classes :)

    Which IMO might be a useful thing. Inner classes definitely have their uses - maybe more so in Java.

    • And along the lines of what I said earlier, here's my first test case with it:


      use strict;
      use warnings;

      use lib 'lib', 't/lib';
      use Test::Most 'no_plan'; # tests => 1;
      use Test::XML;
      use Bermuda::Test;
      use Bermuda::XML;
      use Class::Dummy;

      my $dummy = Class::Dummy->new(
          package => 'Some::Class',
          methods => {
              name => 'Victoria',
              email => sub {
                  my $self = shift;
                  my %email = (
                      personal => '',
                      work     => '',
                  return $email{+shift};
              to_xml => sub {
                  require Some::Class::Bermuda;
                  require Bermuda::XML;
                  return Bermuda::XML->new->render(
      my $island = <<'END_ISLAND';
      package: Some::Class
      island: dummy
      name: dummy
          type: string
        - personal_email
        - type: string
          method: email('personal')
        - work_email
        - type: string
          method: email('work')


      my $expected = <<'END_XML';
      <?xml version="1.0" encoding="utf-8"?>
      <dummy name="Victoria">
      is_xml $dummy->to_xml, $expected,
          'Methods with args should correctly serialize to XML';

      To my mind, that shows me that the &to_xml method is problematic. I can automate that. People need to be able to create a Bermuda project and then make it simple by dropping this into their classes:

      package Some::Company::Invoice;

      use Class::Trait 'Some::Company::Bermuda';

      And then the Some::Company::Invoice class automatically gets a &to_xml method. Already have a &to_xml method?

      package Some::Company::Invoice;

      use Class::Trait (
          'Some::Company::Bermuda' => {
              alias => { to_xml => 'as_xml' },