Rubyish-Attribute
view release on metacpan or search on metacpan
t/lib/Rubyish/AttributeOld.pm view on Meta::CPAN
if ($arg) {
$self->{$field} = $arg;
$self;
} else {
$self->{$field};
}
}
};
for my $field (@_) {
*{(caller)[0] . "::" . $field} = $make_accessor->($field);
}
}
=head2 attr_reader(@list)
attr_reader create only getter for the class you call it
attr_reader qw(name) # pass a list
$dogy = Animal->new({name => "rock"}) # if we write initialize function in constructor
$dogy->name() #=> rock
t/lib/Rubyish/AttributeOld.pm view on Meta::CPAN
if ($arg) {
warn "error - $field is only reader\n";
return; # because no writer
} else {
$self->{$field};
}
}
};
for my $field (@_) {
*{(caller)[0] . "::" . $field} = $make_reader->($field);
}
}
=head2 attr_writer(@list)
attr_writer create only setter for the class you call it.
attr_writer qw(name) # pass a list
$dogy = Animal->new()->name("lucky") # initialize and set and get instance itself
$dogy->name("jack") #=> instance itself
t/lib/Rubyish/AttributeOld.pm view on Meta::CPAN
$self->{$field} = $arg;
$self;
} else {
warn "error - $field is only writer\n";
return; # because no reader
}
}
};
for my $field (@_) {
*{(caller)[0] . "::" . $field} = $make_writer->($field);
}
}
=head1 DEPENDENCE
L<Sub::Exporter>
=head1 SEE ALSO
L<Sub::Exporter>, L<autobox::Core>, L<List::Rubyish>
( run in 1.126 second using v1.01-cache-2.11-cpan-a3c8064c92c )