/[suikacvs]/webroot/swe/lib/SWE/Object/Node.pm
Suika

Contents of /webroot/swe/lib/SWE/Object/Node.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Sun Mar 15 13:07:13 2009 UTC (16 years, 1 month ago) by wakaba
Branch: MAIN
Changes since 1.1: +6 -0 lines
++ swe/lib/SWE/Object/ChangeLog	15 Mar 2009 13:06:41 -0000
	* Node.pm (document_id): New method.

2009-03-15  Wakaba  <wakaba@suika.fam.cx>

++ swe/lib/suikawiki/ChangeLog	15 Mar 2009 13:07:01 -0000
	* main.pl: Dump the name of neighbors.

2009-03-15  Wakaba  <wakaba@suika.fam.cx>

1 wakaba 1.1 package SWE::Object::Node;
2     use strict;
3     use warnings;
4    
5     sub new ($%) {
6     my $class = shift;
7     my $self = bless {@_}, $class;
8    
9     return $self;
10     } # new
11    
12     sub db { $_[0]->{db} }
13    
14     sub create ($%) {
15     my ($self, %opt) = @_;
16     $self->{id} = $opt{id};
17     } # create
18    
19     sub load ($%) {
20     my ($self, %opt) = @_;
21     $self->{id} = $opt{id};
22     } # load
23    
24     sub id ($) { $_[0]->{id} }
25    
26     sub prop ($) {
27     my $self = shift;
28    
29     ## TODO: lock
30    
31     return $self->{prop} ||= do {
32     my $graph_prop_db = $self->db->graph_prop;
33     $graph_prop_db->get_data ($self->id) || {};
34     };
35     } # prop
36    
37     sub save_prop ($) {
38     my $self = shift;
39    
40     return unless defined $self->{prop};
41    
42     ## TODO: lock
43    
44     my $graph_prop_db = $self->db->graph_prop;
45     $graph_prop_db->set_data ($self->id => $self->prop);
46     } # save_prop
47    
48     sub neighbor_ids ($) {
49     my $self = shift;
50    
51     return $self->prop->{neighbors} || {};
52     } # neighbor_ids
53    
54 wakaba 1.2 sub document_id ($) {
55     my $self = shift;
56    
57     return [keys %{$self->prop->{ids} or {}}]->[0];
58     } # document_id
59    
60 wakaba 1.1 1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24