Name

QBit::Application - base class for create applications.

Description

It union all project models.

RO accessors

  • timelog

Package methods

config_opts

Short method description

Arguments:

  • %opts - additional arguments:

Return value: type, description

use_config

Short method description

Arguments:

  • $filename - type, description

Return value: type, description

Methods

get_option

return option by name

Arguments:

  • $name - string

  • $default - default value

Return value: value

#> pwd
#
# /home/app
#
#> cat ./lib/Application.cfg
#
# salt => 'terc3s',
# path => '${ApplicationPath}data',
# lib  => ['./t_lib', '${ApplicationPath}lib'],
# opt  => {
#     key => 'value',
# }

my $salt = $self->get_option('salt', 's3cret'); # 'terc3s'

my $salt2 = $self->get_option('salt2', 's3cret'); # 's3cret'

my $path = $self->get_option('path'); # '/home/app/data'

my $lib = $self->get_option('lib'); # ['./t_lib', '/home/app/lib']

my $opts = $self->get_option('opt', {key => 'value2'}); # {key => 'value'}

set_option

set option

Arguments:

  • $name - string

  • $value - value

Return value: value

$app->set_option('salt', 's3cret');

$app->set_option('locales', [qw(ru en)]);

cur_user

set or get current user

Arguments:

  • $user - hash ref

Return value: hash ref

my $user = {id => 1};

$cur_user = $app->cur_user($user); # set current user

# if use rbac
# {id => 1, roles => {3 => {id => 3, name => 'ROLE 3', description => 'ROLE 3'}}, rights => ['RIGHT1', 'RIGHT2']}
# or
# {id => 1}

$cur_user = $app->cur_user(); # return current user or {}

$app->cur_user({}); # remove current user

set_cur_user_rights

set rights for current user

Arguments:

  • $rights - array ref

$app->set_cur_user_rights([qw(RIGHT1 RIGHT2)]);

revoke_cur_user_rights

revoke rights for current user

Arguments:

  • $rights - array ref

$app->revoke_cur_user_rights([qw(RIGHT1 RIGHT2)]);

refresh_rights

refresh rights for current user

my $cur_user_id = $app->cur_user()->{'id'};

$app->rbac->set_user_role($cur_user_id, 3); # role_id = 3

$app->refresh_rights();

get_models

Short method description

No arguments.

Return value: type, description

get_registered_rights

Short method description

No arguments.

Return value: type, description

get_registered_right_groups

Short method description

No arguments.

Return value: type, description

check_rights

check rights for current user

Arguments:

  • @rights - array of strings or array ref

Return value: boolean

$app->check_rights('RIGHT1', 'RIGHT2'); # TRUE if has rights 'RIGHT1' and 'RIGHT2'

$app->check_rights(['RIGHT1', 'RIGHT2']); # TRUE if has rights 'RIGHT1' or 'RIGHT2'

set_app_locale

Short method description

Arguments:

  • $locale_id - type, description

Return value: type, description

set_tmp_app_locale

Short method description

Arguments:

  • $locale_id - type, description

Return value: type, description

add_tmp_rights

Short method description

Arguments:

  • @rights - type, description

Return value: type, description

pre_run

Short method description

No arguments.

Return value: type, description

post_run

Short method description

No arguments.

Return value: type, description

process_mem_cycles

Short method description

Arguments:

  • $cycles - type, description

Return value: type, description

process_timelog

Short method description

No arguments.

Return value: type, description

_push_pkg_opts

Short method description

Arguments:

  • $filename - type, description

  • $config - type, description

Return value: type, description