NAME

Nile::Var - Application Shared variables.

SYNOPSIS

# get  a reference to the the shared var object
$var = $self->app->var;

# set some variables
$var->set('email', 'ahmed@mewsoft.com');
$var->set('path', '/var/home/public_html/app');
$var->set('lang', 'en-US');

# auto setters
$var->email('ahmed@mewsoft.com');
$var->lang('en-US');

# get some variables
$mail = $var->get('email');
$path = $var->get('path');
$lang = $var->get('lang');

# auto getters
$mail = $var->email;
$lang = $var->lang;

# get variables or default values
$value = $var->get('name', 'default');
$path = $var->get('email', 'root@localhost');

# set a list of variables 
$var->set(%vars);
$var->set(fname=>'Ahmed', lname=>'Elsheshtawy', email=>'ahmed@mewsoft.com');

# get a list of variables 
@values = $var->list(@vars);

# get a list of variables names
@names = $var->keys;

# get a hash reference to the variables
$vars = $var->vars;
$vars->{path} = '/app/path';
say $vars->{theme};

# check if variables exist
$found = $self->exists($name);

# delete some vars
$self->delete(@vars);

# clear all vars
$self->clear;

DESCRIPTION

Nile::Var - Application Shared variables.

clear()

# delete entire xml object data.
$xml->clear();

Completely clears all loaded xml data from memory. This does not apply to the file until file is updated or saved.

vars()

# get all variables as a hash or a hash ref.
%vars = $var->vars();
$vars = $var->vars();

Returns all variables as a hash or a hash reference.

set()

# set variables.
$var->set("users_count", $count);
$var->set(%vars);

# automatic setter support
$var->email('ahmed@mewsoft.com'); # same as $var->set('email', 'ahmed@mewsoft.com');

Set shared variables.

get()

# get variables
say $var->get("email");
say $var->get("website", "default value");
    
# automatic getter support
say $var->email; # same as $var->get('email');

Returns shared variables.

list()

# get a list of shared variables.
@vars = $var->list(@names);

Returns a list of shared variables.

keys()

# returns all variables names.
@names = $var->keys($);

Returns all shared variables names.

exists()

# check if a variable exist or not.
$found = $var->exists($name);

Check if a shared variable exist or not.

delete()

# delete shared variables.
$var->delete(@names);

Delete a list of shared variables.

Bugs

This project is available on github at https://github.com/mewsoft/Nile.

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/Nile.

SOURCE

Source repository is at https://github.com/mewsoft/Nile.

SEE ALSO

See Nile for details about the complete framework.

AUTHOR

Ahmed Amin Elsheshtawy, احمد امين الششتاوى <mewsoft@cpan.org> Website: http://www.mewsoft.com

COPYRIGHT AND LICENSE

Copyright (C) 2014-2015 by Dr. Ahmed Amin Elsheshtawy احمد امين الششتاوى mewsoft@cpan.org, support@mewsoft.com, https://github.com/mewsoft/Nile, http://www.mewsoft.com

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.