X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FPurePerl.pm;h=a5a7502c3f1445c945eb639a0739d55b2baf1039;hb=6c7491f2df2cc362ae9d58ff3660f2286a22f878;hp=d62be9141b797c1a440883159d7d382649c6a5f5;hpb=6e1e5b31f9ff0a46de1d7e396840da18c385962d;p=gitmo%2FMouse.git diff --git a/lib/Mouse/PurePerl.pm b/lib/Mouse/PurePerl.pm index d62be91..a5a7502 100644 --- a/lib/Mouse/PurePerl.pm +++ b/lib/Mouse/PurePerl.pm @@ -148,12 +148,7 @@ sub Value { defined($_[0]) && !ref($_[0]) } sub Num { looks_like_number($_[0]) } sub Int { my($value) = @_; - looks_like_number($value) && do{ - # work around RT #55048 - # This is for more than 32 bit int on 32 bit systems - require POSIX; - POSIX::fmod($value, 1) == 0; - }; + looks_like_number($value) && $value =~ /\A [+-]? [0-9]+ \z/xms; } sub Str { my($value) = @_; @@ -285,7 +280,7 @@ sub new_object { } sub _initialize_object{ - my($self, $object, $args, $ignore_triggers) = @_; + my($self, $object, $args, $is_cloning) = @_; my @triggers_queue; @@ -305,7 +300,7 @@ sub _initialize_object{ } else { # no init arg if ($attribute->has_default || $attribute->has_builder) { - if (!$attribute->is_lazy) { + if (!$attribute->is_lazy && !exists $object->{$slot}) { my $default = $attribute->default; my $builder = $attribute->builder; my $value = $builder ? $object->$builder() @@ -318,13 +313,13 @@ sub _initialize_object{ if ref($object->{$slot}) && $attribute->is_weak_ref; } } - elsif($attribute->is_required) { + elsif(!$is_cloning && $attribute->is_required) { $self->throw_error("Attribute (".$attribute->name.") is required"); } } } - if(!$ignore_triggers){ + if(@triggers_queue){ foreach my $trigger_and_value(@triggers_queue){ my($trigger, $value) = @{$trigger_and_value}; $trigger->($object, $value); @@ -622,6 +617,12 @@ sub compile_type_constraint{ return; } +sub check { + my $self = shift; + return $self->_compiled_type_constraint->(@_); +} + + package Mouse::Object; sub BUILDARGS { @@ -719,7 +720,7 @@ Mouse::PurePerl - A Mouse guts in pure Perl =head1 VERSION -This document describes Mouse version 0.50_06 +This document describes Mouse version 0.55 =head1 SEE ALSO