NAME

Data::Object::Vars

ABSTRACT

Data-Object Environment Variables

SYNOPSIS

use Data::Object::Vars;

my $vars = Data::Object::Vars->new(
  named => { iam => 'USER', root => 'HOME' }
);

$vars->root; # $ENV{HOME}
$vars->home; # $ENV{HOME}
$vars->get('home'); # $ENV{HOME}
$vars->get('HOME'); # $ENV{HOME}

$vars->iam; # $ENV{USER}
$vars->user; # $ENV{USER}
$vars->get('user'); # $ENV{USER}
$vars->get('USER'); # $ENV{USER}

DESCRIPTION

This package provides an object-oriented interface to the process' environment variables.

INTEGRATIONS

This package integrates behaviors from:

Data::Object::Role::Stashable

LIBRARIES

This package uses type constraints defined by:

Data::Object::Library

ATTRIBUTES

This package has the following attributes.

named

named(HashRef)

The attribute is read-only, accepts (HashRef) values, and is optional.

METHODS

This package implements the following methods.

exists

exists(Str $key) : Any

The exists method takes a name and returns truthy if an associated value exists.

exists example
$vars->exists('home'); # exists $ENV{HOME}
$vars->exists('HOME'); # exists $ENV{HOME}

get

get(Str $key) : Any

The get method takes a name and returns the associated value.

get example
$vars->get('home'); # $ENV{HOME}
$vars->get('HOME'); # $ENV{HOME}

name

name(Str $key) : Any

The name method takes a name and returns stash key if the the associated value exists.

name example
$vars->name('root'); # HOME
$vars->name('home'); # HOME
$vars->name('HOME'); # HOME

set

set(Str $key, Maybe[Any] $value) : Any

The set method takes a name and sets the value provided if the associated argument exists.

set example
$vars->set('home', '/tmp'); # /tmp
$vars->set('HOME', '/tmp'); # /tmp

stashed

stashed() : HashRef

The stashed method returns the stashed data associated with the object.

stashed example
$vars->stashed; # {...}

CREDITS

Al Newkirk, +319

Anthony Brummett, +10

Adam Hopkins, +2

José Joaquín Atria, +1

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 here, https://github.com/iamalnewkirk/do/blob/master/LICENSE.

PROJECT

Wiki

Project

Initiatives

Milestones

Contributing

Issues

SEE ALSO

To get the most out of this distribution, consider reading the following:

Do

Data::Object

Data::Object::Class

Data::Object::ClassHas

Data::Object::Role

Data::Object::RoleHas

Data::Object::Library