instance-protocol
[gitmo/Class-MOP.git] / lib / Class / MOP / Instance.pm
index 7d1e573..9d47700 100644 (file)
@@ -18,7 +18,7 @@ sub new {
     my $class = shift;
     my $meta  = shift;
     bless {
-        instance => bless {} => $meta->name
+        instance => (bless {} => $meta->name)
     } => $class; 
 }
 
@@ -27,6 +27,26 @@ sub add_slot {
     return $self->{instance}->{$slot_name} = $value;
 }
 
+sub has_slot {
+    my ($self, $slot_name) = @_;
+    exists $self->{instance}->{$slot_name} ? 1 : 0;
+}
+
+sub get_slot_value {
+    my ($self, $instance, $slot_name) = @_;
+    return $instance->{$slot_name};
+}
+
+sub set_slot_value {
+    my ($self, $instance, $slot_name, $value) = @_;
+    $instance->{$slot_name} = $value;
+}
+
+sub has_slot_value {
+    my ($self, $instance, $slot_name) = @_;
+    defined $instance->{$slot_name} ? 1 : 0;
+}
+
 sub get_instance { (shift)->{instance} }
 
 1;
@@ -51,6 +71,14 @@ Class::MOP::Instance - Instance Meta Object
 
 =item B<add_slot>
 
+=item B<has_slot>
+
+=item B<get_slot_value>
+
+=item B<set_slot_value>
+
+=item B<has_slot_value>
+
 =item B<get_instance>
 
 =back