tweaking the attribute initializer stuff a little
[gitmo/Class-MOP.git] / lib / Class / MOP / Instance.pm
index baac84b..a9d5a5d 100644 (file)
@@ -6,7 +6,7 @@ use warnings;
 
 use Scalar::Util 'weaken', 'blessed';
 
-our $VERSION   = '0.03';
+our $VERSION   = '0.04';
 our $AUTHORITY = 'cpan:STEVAN';
 
 sub meta {
@@ -63,14 +63,14 @@ sub get_all_slots {
 
 sub is_valid_slot {
     my ($self, $slot_name) = @_;
-    exists $self->{'@!slots'}->{$slot_name} ? 1 : 0;
+    exists $self->{'@!slots'}->{$slot_name};
 }
 
 # operations on created instances
 
 sub get_slot_value {
     my ($self, $instance, $slot_name) = @_;
-    $self->is_slot_initialized($instance, $slot_name) ? $instance->{$slot_name} : undef;
+    $instance->{$slot_name};
 }
 
 sub set_slot_value {
@@ -104,7 +104,7 @@ sub deinitialize_all_slots {
 
 sub is_slot_initialized {
     my ($self, $instance, $slot_name, $value) = @_;
-    exists $instance->{$slot_name} ? 1 : 0;
+    exists $instance->{$slot_name};
 }
 
 sub weaken_slot_value {
@@ -138,8 +138,7 @@ sub inline_slot_access {
 
 sub inline_get_slot_value {
     my ($self, $instance, $slot_name) = @_;
-    'exists ' . $self->inline_slot_access($instance, $slot_name) .
-    ' ? ' . $self->inline_slot_access($instance, $slot_name) . ' : undef'
+    $self->inline_slot_access($instance, $slot_name);
 }
 
 sub inline_set_slot_value {
@@ -158,7 +157,7 @@ sub inline_deinitialize_slot {
 }
 sub inline_is_slot_initialized {
     my ($self, $instance, $slot_name) = @_;
-    "exists " . $self->inline_slot_access($instance, $slot_name) . " ? 1 : 0";
+    "exists " . $self->inline_slot_access($instance, $slot_name);
 }
 
 sub inline_weaken_slot_value {
@@ -183,24 +182,19 @@ Class::MOP::Instance - Instance Meta Object
 
 =head1 SYNOPSIS
 
-  # for the most part, this protocol is internal
-  # and not for public usage, but this how one
-  # might use it
-
-  package Foo;
-
-  use strict;
-  use warnings;
-  use metaclass (
-      ':instance_metaclass'  => 'ArrayBasedStorage::Instance',
-  );
-
-  # now Foo->new produces blessed ARRAY ref based objects
+    # This API is largely internal
+    # you shouldn't need it unless you are writing meta attributes or meta
+    # instances
 
 =head1 DESCRIPTION
 
-This is a sub-protocol which governs instance creation
-and access to the slots of the instance structure.
+The meta instance is used by attributes for low level storage.
+
+Using this API generally violates attribute encapsulation and is not
+reccomended, instead look at L<Class::MOP::Attribute/get_value>,
+L<Class::MOP::Attribute/set_value> for the reccomended way to fiddle with
+attribute values in a generic way, independant of how/whether accessors have
+been defined. Accessors can be found using L<Class::MOP::Class/get_attribute>.
 
 This may seem like over-abstraction, but by abstracting
 this process into a sub-protocol we make it possible to