Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
yuki-kimoto committed Dec 22, 2009
1 parent e417927 commit 2ccb675
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
2.1101
add 'Object::Simple::Util::init_attrs'
2.1002
add 'new' function to 'Object::Simple::Accessor';
2.1001
Expand Down
4 changes: 2 additions & 2 deletions lib/Object/Simple.pm
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,11 @@ Object::Simple - Simple class builder
=head1 VERSION
Version 2.1002
Version 2.1101
=cut

our $VERSION = '2.1002';
our $VERSION = '2.1101';

=head1 FEATURES
Expand Down
12 changes: 8 additions & 4 deletions lib/Object/Simple/Util.pm
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ sub create_accessor {
my $strage;
if ($accessor_type eq 'ClassAttr') {
# Strage package Varialbe in case class accessor
$strage = "Object::Simple::Util->class_infos->{\$self}{class_attrs}{'$accessor_name'}";
$strage = "Object::Simple::Util->class_attrs(\$self)->{'$accessor_name'}";
$source .=
qq/ Carp::croak("${class}::$accessor_name must be called from class, not instance")\n/ .
qq/ if ref \$self;\n/;
Expand Down Expand Up @@ -766,7 +766,11 @@ sub class_attrs {

my $class = ref $invocant || $invocant;

return $self->class_infos->{$class}{class_attrs};
no strict 'refs';
${"${class}::CLASS_ATTRS"} ||= {};
my $class_attrs = ${"${class}::CLASS_ATTRS"};

return $class_attrs;
}

# Class attribute is exsist?
Expand All @@ -775,7 +779,7 @@ sub exists_class_attr {

my $class = ref $invocant || $invocant;

return exists $self->class_infos->{$class}{class_attrs}{$accessor_name};
return exists $self->class_attrs($class)->{$accessor_name};
}

# Delete class attribute
Expand All @@ -784,7 +788,7 @@ sub delete_class_attr {

my $class = ref $invocant || $invocant;

return delete $self->class_infos->{$class}{class_attrs}{$accessor_name};
return delete $self->class_attrs($class)->{$accessor_name};
}

sub init_attrs {
Expand Down

0 comments on commit 2ccb675

Please sign in to comment.