1 package SL::Auth::SessionValue;
5 use Scalar::Util qw(weaken);
11 my ($class, %params) = @_;
13 my $self = bless {}, $class;
15 map { $self->{$_} = $params{$_} } qw(auth key value auto_restore);
17 $self->{fetched} = exists $params{value};
18 $self->{parsed} = !$params{raw} && exists $params{value};
20 # delete $self->{auth};
21 # $::lxdebug->dump(0, "NEW", $self);
22 # $self->{auth} = $params{auth};
31 return $self->_fetch->_parse->{value};
36 return YAML::Dump($self->get);
42 return $self if $self->{fetched};
44 my $dbh = $self->{auth}->dbconnect;
45 my $query = qq|SELECT sess_value FROM auth.session_content WHERE (session_id = ?) AND (sess_key = ?)|;
46 ($self->{value}) = selectfirst_array_query($::form, $dbh, $query, $self->{auth}->get_session_id, $self->{key});
55 $self->{value} = YAML::Load($self->{value}) unless $self->{parsed};
62 my ($self, $value) = @_;
64 return { simple => 1, data => $value } if $value !~ m/^---/;
66 my %params = ( simple => 1 );
68 my $data = YAML::Load($value);
70 if (ref $data eq 'HASH') {
71 map { $params{$_} = $data->{$_} } keys %{ $data };
75 $params{data} = $data;
79 } or $params{data} = $value;