/[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.1 - (hide annotations) (download)
Sun Mar 15 12:50:04 2009 UTC (16 years, 1 month ago) by wakaba
Branch: MAIN
++ swe/lib/SWE/Object/ChangeLog	15 Mar 2009 12:49:18 -0000
	* Graph.pm (get_node_by_id): New method.
	(create_node): Changed to instantiate SWE::Object::Node.

	* Node.pm: New module.

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

++ swe/lib/suikawiki/ChangeLog	15 Mar 2009 12:49:58 -0000
	* main.pl: Dump the list 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     1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24