OSDN Git Service

add Queue client class
authorISHIKAWA Mutsumi <ishikawa@hanzubon.jp>
Fri, 2 Nov 2012 09:46:34 +0000 (18:46 +0900)
committerISHIKAWA Mutsumi <ishikawa@hanzubon.jp>
Fri, 2 Nov 2012 09:46:34 +0000 (18:46 +0900)
lib/Mubot4FB/Queue/Client.pm

index 98e6de3..7359830 100644 (file)
@@ -3,21 +3,28 @@
 # Copyright (c) 2012 ISHIKAWA Mutsumi <ishikawa@hanzubon.jp>
 # This program is covered by the GNU General Public License 2
 #
-package Mubot4FB::Queue;
+package Mubot4FB::Queue::Client;
 use strict;
 use utf8;
 
-use base 'Qudo';
+use base 'Jonk::Client';
+
+use JSON::XS;
 
 use Data::Dumper;
 
 sub new {
-       my ($class, $cfg) = @_;
-       $class->SUPER::new(driver_class => 'DBI',
-                          databases => [+{dsn => 'DBI:mysql:'.$cfg->{database},
-                                          username => $cfg->{db_user},
-                                          password => $cfg->{db_pass}}],
-                          default_hooks => [qw/Qudo::Hook::Serialize::JSON/]);
+       my ($class, $cfg, $dbh) = @_;
+       my $self = $class->SUPER::new($dbh);
+       $self->{cfg} = $cfg;
+       bless $self, $class;
+       return $self;
+}
+
+sub enqueue {
+       my ($me, $func, $args) = @_;
+       my $enc_args = encode_json($args);
+       $me->SUPER::enqueue($func, $enc_args);
 }
 
 1;