Browse files

Moved code within file, no changes

  • Loading branch information...
1 parent f1b5331 commit bdf0a67537a750f66055f93b68a82533a4f9dea0 @clintongormley committed Aug 1, 2012
Showing with 31 additions and 30 deletions.
  1. +31 −30 lib/Elastic/Model/Trait/Field.pm
View
61 lib/Elastic/Model/Trait/Field.pm
@@ -13,6 +13,37 @@ use Carp;
use namespace::autoclean;
#===================================
+
+#===================================
+before '_process_options' => sub {
+#===================================
+ my ( $class, $name, $opts ) = @_;
+ if ( my $orig = $opts->{trigger} ) {
+ ( 'CODE' eq ref $orig )
+ || $class->throw_error(
+ "Trigger must be a CODE ref on attribute ($name)",
+ data => $opts->{trigger} );
+ $opts->{trigger} = sub {
+ my $self = shift;
+ no warnings 'uninitialized';
+ unless ( @_ == 2 && $_[1] eq $_[0] ) {
+ $self->has_changed( $name, $_[1] );
+ }
+ $self->$orig(@_);
+ };
+ }
+ else {
+
+ $opts->{trigger} = sub {
+ my $self = shift;
+ no warnings 'uninitialized';
+ unless ( @_ == 2 && $_[1] eq $_[0] ) {
+ $self->has_changed( $name, $_[1] );
+ }
+ };
+ }
+};
+
has 'type' => (
#===================================
isa => FieldType,
@@ -246,36 +277,6 @@ has 'exclude_attrs' => (
is => 'ro'
);
-#===================================
-before '_process_options' => sub {
-#===================================
- my ( $class, $name, $opts ) = @_;
- if ( my $orig = $opts->{trigger} ) {
- ( 'CODE' eq ref $orig )
- || $class->throw_error(
- "Trigger must be a CODE ref on attribute ($name)",
- data => $opts->{trigger} );
- $opts->{trigger} = sub {
- my $self = shift;
- no warnings 'uninitialized';
- unless ( @_ == 2 && $_[1] eq $_[0] ) {
- $self->has_changed( $name, $_[1] );
- }
- $self->$orig(@_);
- };
- }
- else {
-
- $opts->{trigger} = sub {
- my $self = shift;
- no warnings 'uninitialized';
- unless ( @_ == 2 && $_[1] eq $_[0] ) {
- $self->has_changed( $name, $_[1] );
- }
- };
- }
-};
-
1;
__END__

0 comments on commit bdf0a67

Please sign in to comment.