{
    "content": [
        {
            "type": "text",
            "text": "# Test2::Util::HashBase (perldoc)\n\n## NAME\n\nTest2::Util::HashBase - Build hash based classes.\n\n## SYNOPSIS\n\nA class:\npackage My::Class;\nuse strict;\nuse warnings;\n# Generate 3 accessors\nuse Test2::Util::HashBase qw/foo -bar ^baz <bat >ban +boo/;\n# Chance to initialize defaults\nsub init {\nmy $self = shift;    # No other args\n$self->{+FOO} ||= \"foo\";\n$self->{+BAR} ||= \"bar\";\n$self->{+BAZ} ||= \"baz\";\n$self->{+BAT} ||= \"bat\";\n$self->{+BAN} ||= \"ban\";\n$self->{+BOO} ||= \"boo\";\n}\nsub print {\nprint join \", \" => map { $self->{$} } FOO, BAR, BAZ, BAT, BAN, BOO;\n}\nSubclass it\npackage My::Subclass;\nuse strict;\nuse warnings;\n# Note, you should subclass before loading HashBase.\nuse base 'My::Class';\nuse Test2::Util::HashBase qw/bub/;\nsub init {\nmy $self = shift;\n# We get the constants from the base class for free.\n$self->{+FOO} ||= 'SubFoo';\n$self->{+BUB} ||= 'bub';\n$self->SUPER::init();\n}\nuse it:\npackage main;\nuse strict;\nuse warnings;\nuse My::Class;\n# These are all functionally identical\nmy $one   = My::Class->new(foo => 'MyFoo', bar => 'MyBar');\nmy $two   = My::Class->new({foo => 'MyFoo', bar => 'MyBar'});\nmy $three = My::Class->new(['MyFoo', 'MyBar']);\n# Readers!\nmy $foo = $one->foo;    # 'MyFoo'\nmy $bar = $one->bar;    # 'MyBar'\nmy $baz = $one->baz;    # Defaulted to: 'baz'\nmy $bat = $one->bat;    # Defaulted to: 'bat'\n# '>ban' means setter only, no reader\n# '+boo' means no setter or reader, just the BOO constant\n# Setters!\n$one->setfoo('A Foo');\n#'-bar' means read-only, so the setter will throw an exception (but is defined).\n$one->setbar('A bar');\n# '^baz' means deprecated setter, this will warn about the setter being\n# deprecated.\n$one->setbaz('A Baz');\n# '<bat' means no setter defined at all\n# '+boo' means no setter or reader, just the BOO constant\n$one->{+FOO} = 'xxx';\n\n## DESCRIPTION\n\nThis package is used to generate classes based on hashrefs. Using this class will give you a\n\"new()\" method, as well as generating accessors you request. Generated accessors will be\ngetters, \"setACCESSOR\" setters will also be generated for you. You also get constants for each\naccessor (all caps) which return the key into the hash for that accessor. Single inheritance is\nalso supported.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **THIS IS A BUNDLED COPY OF HASHBASE**\n- **METHODS**\n- **ACCESSORS** (4 subsections)\n- **SUBCLASSING**\n- **GETTING A LIST OF ATTRIBUTES FOR A CLASS**\n- **SOURCE**\n- **MAINTAINERS**\n- **AUTHORS**\n- **COPYRIGHT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Test2::Util::HashBase",
        "section": "",
        "mode": "perldoc",
        "summary": "Test2::Util::HashBase - Build hash based classes.",
        "synopsis": "A class:\npackage My::Class;\nuse strict;\nuse warnings;\n# Generate 3 accessors\nuse Test2::Util::HashBase qw/foo -bar ^baz <bat >ban +boo/;\n# Chance to initialize defaults\nsub init {\nmy $self = shift;    # No other args\n$self->{+FOO} ||= \"foo\";\n$self->{+BAR} ||= \"bar\";\n$self->{+BAZ} ||= \"baz\";\n$self->{+BAT} ||= \"bat\";\n$self->{+BAN} ||= \"ban\";\n$self->{+BOO} ||= \"boo\";\n}\nsub print {\nprint join \", \" => map { $self->{$} } FOO, BAR, BAZ, BAT, BAN, BOO;\n}\nSubclass it\npackage My::Subclass;\nuse strict;\nuse warnings;\n# Note, you should subclass before loading HashBase.\nuse base 'My::Class';\nuse Test2::Util::HashBase qw/bub/;\nsub init {\nmy $self = shift;\n# We get the constants from the base class for free.\n$self->{+FOO} ||= 'SubFoo';\n$self->{+BUB} ||= 'bub';\n$self->SUPER::init();\n}\nuse it:\npackage main;\nuse strict;\nuse warnings;\nuse My::Class;\n# These are all functionally identical\nmy $one   = My::Class->new(foo => 'MyFoo', bar => 'MyBar');\nmy $two   = My::Class->new({foo => 'MyFoo', bar => 'MyBar'});\nmy $three = My::Class->new(['MyFoo', 'MyBar']);\n# Readers!\nmy $foo = $one->foo;    # 'MyFoo'\nmy $bar = $one->bar;    # 'MyBar'\nmy $baz = $one->baz;    # Defaulted to: 'baz'\nmy $bat = $one->bat;    # Defaulted to: 'bat'\n# '>ban' means setter only, no reader\n# '+boo' means no setter or reader, just the BOO constant\n# Setters!\n$one->setfoo('A Foo');\n#'-bar' means read-only, so the setter will throw an exception (but is defined).\n$one->setbar('A bar');\n# '^baz' means deprecated setter, this will warn about the setter being\n# deprecated.\n$one->setbaz('A Baz');\n# '<bat' means no setter defined at all\n# '+boo' means no setter or reader, just the BOO constant\n$one->{+FOO} = 'xxx';",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 79,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "THIS IS A BUNDLED COPY OF HASHBASE",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "METHODS",
                "lines": 50,
                "subsections": []
            },
            {
                "name": "ACCESSORS",
                "lines": 7,
                "subsections": [
                    {
                        "name": "foo",
                        "lines": 2
                    },
                    {
                        "name": "set_foo",
                        "lines": 13
                    },
                    {
                        "name": "set_foo",
                        "lines": 6
                    },
                    {
                        "name": "set_foo",
                        "lines": 17
                    }
                ]
            },
            {
                "name": "SUBCLASSING",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "GETTING A LIST OF ATTRIBUTES FOR A CLASS",
                "lines": 13,
                "subsections": []
            },
            {
                "name": "SOURCE",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "MAINTAINERS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 7,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Test2::Util::HashBase - Build hash based classes.\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "A class:\n\npackage My::Class;\nuse strict;\nuse warnings;\n\n# Generate 3 accessors\nuse Test2::Util::HashBase qw/foo -bar ^baz <bat >ban +boo/;\n\n# Chance to initialize defaults\nsub init {\nmy $self = shift;    # No other args\n$self->{+FOO} ||= \"foo\";\n$self->{+BAR} ||= \"bar\";\n$self->{+BAZ} ||= \"baz\";\n$self->{+BAT} ||= \"bat\";\n$self->{+BAN} ||= \"ban\";\n$self->{+BOO} ||= \"boo\";\n}\n\nsub print {\nprint join \", \" => map { $self->{$} } FOO, BAR, BAZ, BAT, BAN, BOO;\n}\n\nSubclass it\n\npackage My::Subclass;\nuse strict;\nuse warnings;\n\n# Note, you should subclass before loading HashBase.\nuse base 'My::Class';\nuse Test2::Util::HashBase qw/bub/;\n\nsub init {\nmy $self = shift;\n\n# We get the constants from the base class for free.\n$self->{+FOO} ||= 'SubFoo';\n$self->{+BUB} ||= 'bub';\n\n$self->SUPER::init();\n}\n\nuse it:\n\npackage main;\nuse strict;\nuse warnings;\nuse My::Class;\n\n# These are all functionally identical\nmy $one   = My::Class->new(foo => 'MyFoo', bar => 'MyBar');\nmy $two   = My::Class->new({foo => 'MyFoo', bar => 'MyBar'});\nmy $three = My::Class->new(['MyFoo', 'MyBar']);\n\n# Readers!\nmy $foo = $one->foo;    # 'MyFoo'\nmy $bar = $one->bar;    # 'MyBar'\nmy $baz = $one->baz;    # Defaulted to: 'baz'\nmy $bat = $one->bat;    # Defaulted to: 'bat'\n# '>ban' means setter only, no reader\n# '+boo' means no setter or reader, just the BOO constant\n\n# Setters!\n$one->setfoo('A Foo');\n\n#'-bar' means read-only, so the setter will throw an exception (but is defined).\n$one->setbar('A bar');\n\n# '^baz' means deprecated setter, this will warn about the setter being\n# deprecated.\n$one->setbaz('A Baz');\n\n# '<bat' means no setter defined at all\n# '+boo' means no setter or reader, just the BOO constant\n\n$one->{+FOO} = 'xxx';\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This package is used to generate classes based on hashrefs. Using this class will give you a\n\"new()\" method, as well as generating accessors you request. Generated accessors will be\ngetters, \"setACCESSOR\" setters will also be generated for you. You also get constants for each\naccessor (all caps) which return the key into the hash for that accessor. Single inheritance is\nalso supported.\n",
                "subsections": []
            },
            "THIS IS A BUNDLED COPY OF HASHBASE": {
                "content": "This is a bundled copy of Object::HashBase. This file was generated using the\n\"/home/exodist/perl5/perlbrew/perls/main/bin/hashbaseinc.pl\" script.\n",
                "subsections": []
            },
            "METHODS": {
                "content": "PROVIDED BY HASH BASE\n$it = $class->new(%PAIRS)\n$it = $class->new(\\%PAIRS)\n$it = $class->new(\\@ORDEREDVALUES)\nCreate a new instance.\n\nHashBase will not export \"new()\" if there is already a \"new()\" method in your packages\ninheritance chain.\n\nIf you do not want this method you can define your own you just have to declare it before\nloading Test2::Util::HashBase.\n\npackage My::Package;\n\n# predeclare new() so that HashBase does not give us one.\nsub new;\n\nuse Test2::Util::HashBase qw/foo bar baz/;\n\n# Now we define our own new method.\nsub new { ... }\n\nThis makes it so that HashBase sees that you have your own \"new()\" method. Alternatively you\ncan define the method before loading HashBase instead of just declaring it, but that\nscatters your use statements.\n\nThe most common way to create an object is to pass in key/value pairs where each key is an\nattribute and each value is what you want assigned to that attribute. No checking is done to\nverify the attributes or values are valid, you may do that in \"init()\" if desired.\n\nIf you would like, you can pass in a hashref instead of pairs. When you do so the hashref\nwill be copied, and the copy will be returned blessed as an object. There is no way to ask\nHashBase to bless a specific hashref.\n\nIn some cases an object may only have 1 or 2 attributes, in which case a hashref may be too\nverbose for your liking. In these cases you can pass in an arrayref with only values. The\nvalues will be assigned to attributes in the order the attributes were listed. When there is\ninheritance involved the attributes from parent classes will come before subclasses.\n\nHOOKS\n$self->init()\nThis gives you the chance to set some default values to your fields. The only argument is\n$self with its indexes already set from the constructor.\n\nNote: Test2::Util::HashBase checks for an init using \"$class->can('init')\" during\nconstruction. It DOES NOT call \"can()\" on the created object. Also note that the result of\nthe check is cached, it is only ever checked once, the first time an instance of your class\nis created. This means that adding an \"init()\" method AFTER the first construction will\nresult in it being ignored.\n",
                "subsections": []
            },
            "ACCESSORS": {
                "content": "READ/WRITE\nTo generate accessors you list them when using the module:\n\nuse Test2::Util::HashBase qw/foo/;\n\nThis will generate the following subs in your namespace:\n",
                "subsections": [
                    {
                        "name": "foo",
                        "content": "Getter, used to get the value of the \"foo\" field.\n"
                    },
                    {
                        "name": "set_foo",
                        "content": "Setter, used to set the value of the \"foo\" field.\n\nFOO()\nConstant, returns the field \"foo\"'s key into the class hashref. Subclasses will also get\nthis function as a constant, not simply a method, that means it is copied into the subclass\nnamespace.\n\nThe main reason for using these constants is to help avoid spelling mistakes and similar\ntypos. It will not help you if you forget to prefix the '+' though.\n\nREAD ONLY\nuse Test2::Util::HashBase qw/-foo/;\n"
                    },
                    {
                        "name": "set_foo",
                        "content": "Throws an exception telling you the attribute is read-only. This is exported to override any\nactive setters for the attribute in a parent class.\n\nDEPRECATED SETTER\nuse Test2::Util::HashBase qw/^foo/;\n"
                    },
                    {
                        "name": "set_foo",
                        "content": "This will set the value, but it will also warn you that the method is deprecated.\n\nNO SETTER\nuse Test2::Util::HashBase qw/<foo/;\n\nOnly gives you a reader, no \"setfoo\" method is defined at all.\n\nNO READER\nuse Test2::Util::HashBase qw/>foo/;\n\nOnly gives you a write (\"setfoo\"), no \"foo\" method is defined at all.\n\nCONSTANT ONLY\nuse Test2::Util::HashBase qw/+foo/;\n\nThis does not create any methods for you, it just adds the \"FOO\" constant.\n"
                    }
                ]
            },
            "SUBCLASSING": {
                "content": "You can subclass an existing HashBase class.\n\nuse base 'Another::HashBase::Class';\nuse Test2::Util::HashBase qw/foo bar baz/;\n\nThe base class is added to @ISA for you, and all constants from base classes are added to\nsubclasses automatically.\n",
                "subsections": []
            },
            "GETTING A LIST OF ATTRIBUTES FOR A CLASS": {
                "content": "Test2::Util::HashBase provides a function for retrieving a list of attributes for an\nTest2::Util::HashBase class.\n\n@list = Test2::Util::HashBase::attrlist($class)\n@list = $class->Test2::Util::HashBase::attrlist()\nEither form above will work. This will return a list of attributes defined on the object.\nThis list is returned in the attribute definition order, parent class attributes are listed\nbefore subclass attributes. Duplicate attributes will be removed before the list is\nreturned.\n\nNote: This list is used in the \"$class->new(\\@ARRAY)\" constructor to determine the attribute\nto which each value will be paired.\n",
                "subsections": []
            },
            "SOURCE": {
                "content": "The source code repository for HashBase can be found at http://github.com/Test-More/HashBase/.\n",
                "subsections": []
            },
            "MAINTAINERS": {
                "content": "Chad Granum <exodist@cpan.org>\n",
                "subsections": []
            },
            "AUTHORS": {
                "content": "Chad Granum <exodist@cpan.org>\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "Copyright 2017 Chad Granum <exodist@cpan.org>.\n\nThis program is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n\nSee http://dev.perl.org/licenses/\n",
                "subsections": []
            }
        }
    }
}