NAME

Data::Object::Space - Namespace Class

ABSTRACT

Namespace Class for Perl 5

SYNOPSIS

package main;

use Data::Object::Space;

my $space = Data::Object::Space->new('foo/bar');

DESCRIPTION

This package provides methods for parsing and manipulating package namespaces.

INHERITS

This package inherits behaviors from:

Data::Object::Name

LIBRARIES

This package uses type constraints from:

Types::Standard

METHODS

This package implements the following methods:

all

all(Str $name, Any @args) : ArrayRef[Tuple[Str, Any]]

The all method executes any available method on the instance and all instances representing packages inherited by the package represented by the invocant.

append

append(Str @args) : Object

The append method modifies the object by appending to the package namespace parts.

array

array(Str $arg1) : ArrayRef

The array method returns the value for the given package array variable name.

arrays

arrays() : ArrayRef

The arrays method searches the package namespace for arrays and returns their names.

authority

authority() : Maybe[Str]

The authority method returns the AUTHORITY declared on the target package, if any.

base

base() : Str

The base method returns the last segment of the package namespace parts.

bless

bless(Any $arg1 = {}) : Object

The bless method blesses the given value into the package namespace and returns an object. If no value is given, an empty hashref is used.

build

build(Any @args) : Object

The build method attempts to call new on the package namespace and if successful returns the resulting object.

call

call(Any @args) : Any

The call method attempts to call the given subroutine on the package namespace and if successful returns the resulting value.

chain

chain(Str | Tuple[Str, Any] @steps) : Any

The chain method chains one or more method calls and returns the result.

child

child(Str $arg1) : Object

The child method returns a new Data::Object::Space object for the child package namespace.

children

children() : ArrayRef[Object]

The children method searches %INC and @INC and retuns a list of Data::Object::Space objects for each child namespace found (one level deep).

cop

cop(Any @args) : CodeRef

The cop method attempts to curry the given subroutine on the package namespace and if successful returns a closure.

data

data() : Str

The data method attempts to read and return any content stored in the DATA section of the package namespace.

destroy

destroy() : Object

The destroy method attempts to wipe out a namespace and also remove it and its children from %INC. NOTE: This can cause catastrophic failures if used incorrectly.

eval

eval(Str @args) : Any

The eval method takes a list of strings and evaluates them under the namespace represented by the instance.

functions

functions() : ArrayRef

The functions method searches the package namespace for functions and returns their names.

hash

hash(Str $arg1) : HashRef

The hash method returns the value for the given package hash variable name.

hashes

hashes() : ArrayRef

The hashes method searches the package namespace for hashes and returns their names.

id

id() : Str

The id method returns the fully-qualified package name as a label.

included

included() : Str

The included method returns the path of the namespace if it exists in %INC.

inherits

inherits() : ArrayRef

The inherits method returns the list of superclasses the target package is derived from.

init

init() : Str

The init method ensures that the package namespace is loaded and, whether created in-memory or on-disk, is flagged as being loaded and loadable.

inject

inject(Str $name, Maybe[CodeRef] $coderef) : Any

The inject method monkey-patches the package namespace, installing a named subroutine into the package which can then be called normally, returning the fully-qualified subroutine name.

load

load() : Str

The load method checks whether the package namespace is already loaded and if not attempts to load the package. If the package is not loaded and is not loadable, this method will throw an exception using confess. If the package is loadable, this method returns truthy with the package name. As a workaround for packages that only exist in-memory, if the package contains a new, with, meta, or import routine it will be recognized as having been loaded.

loaded

loaded() : Int

The loaded method checks whether the package namespace is already loaded returns truthy or falsy.

locate

locate() : Str

The locate method checks whether the package namespace is available in @INC, i.e. on disk. This method returns the file if found or an empty string.

methods

methods() : ArrayRef

The methods method searches the package namespace for methods and returns their names.

name

name() : Str

The name method returns the fully-qualified package name.

parent

parent() : Object

The parent method returns a new Data::Object::Space object for the parent package namespace.

parse

parse() : ArrayRef

The parse method parses the string argument and returns an arrayref of package namespace segments (parts).

parts

parts() : ArrayRef

The parts method returns an arrayref of package namespace segments (parts).

prepend

prepend(Str @args) : Object

The prepend method modifies the object by prepending to the package namespace parts.

rebase

rebase(Str @args) : Object

The rebase method returns an object by prepending the package namespace specified to the base of the current object's namespace.

reload

reload() : Str

The reload method attempts to delete and reload the package namespace using the "load" method. Note: Reloading is additive and will overwrite existing symbols but does not remove symbols.

require

require(Str $target) : Any

The require method executes a require statement within the package namespace specified.

root

root() : Str

The root method returns the root package namespace segments (parts). Sometimes separating the root from the parts helps identify how subsequent child objects were derived.

routine

routine(Str $arg1) : CodeRef

The routine method returns the subroutine reference for the given subroutine name.

routines

routines() : ArrayRef

The routines method searches the package namespace for routines and returns their names.

scalar

scalar(Str $arg1) : Any

The scalar method returns the value for the given package scalar variable name.

scalars

scalars() : ArrayRef

The scalars method searches the package namespace for scalars and returns their names.

sibling

sibling(Str $arg1) : Object

The sibling method returns a new Data::Object::Space object for the sibling package namespace.

siblings

siblings() : ArrayRef[Object]

The siblings method searches %INC and @INC and retuns a list of Data::Object::Space objects for each sibling namespace found (one level deep).

tryload

tryload() : Bool

The tryload method attempt to load the represented package using the "load" method and returns truthy/falsy based on whether the package was loaded.

use

use(Str | Tuple[Str, Str] $target, Any @params) : Object

The use method executes a use statement within the package namespace specified.

used

used() : Str

The used method searches %INC for the package namespace and if found returns the filepath and complete filepath for the loaded package, otherwise returns falsy with an empty string.

variables

variables() : ArrayRef[Tuple[Str, ArrayRef]]

The variables method searches the package namespace for variables and returns their names.

version

version() : Maybe[Str]

The version method returns the VERSION declared on the target package, if any.

AUTHOR

Al Newkirk, awncorp@cpan.org

LICENSE

Copyright (C) 2011-2019, Al Newkirk, et al.

This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file".

PROJECT

Wiki

Project

Initiatives

Milestones

Contributing

Issues