Browse files

More bug fixes to do with the removal of the doc class wrapper

  • Loading branch information...
1 parent 78a7200 commit b6f7919a2ec68cc7ec74e0ea817d9e2ca52ba923 @clintongormley committed Mar 19, 2012
Showing with 13 additions and 18 deletions.
  1. +3 −0 lib/Elastic/Model/Role/Doc.pm
  2. +5 −11 lib/Elastic/Model/TypeMap/Base.pm
  3. +5 −7 lib/Elastic/Model/TypeMap/Objects.pm
View
3 lib/Elastic/Model/Role/Doc.pm
@@ -19,6 +19,7 @@ has 'uid' => (
required => 1,
writer => '_set_uid',
traits => ['Elastic::Model::Trait::Exclude'],
+ exclude => 1,
handles => {
id => 'id',
type => 'type',
@@ -33,6 +34,7 @@ has '_can_inflate' => (
is => 'rw',
default => 0,
traits => ['Elastic::Model::Trait::Exclude'],
+ exclude => 1,
);
#===================================
@@ -42,6 +44,7 @@ has '_source' => (
is => 'ro',
traits => ['Elastic::Model::Trait::Exclude'],
lazy => 1,
+ exclude => 1,
builder => '_get_source',
writer => '_overwrite_source',
clearer => '_clear_source',
View
16 lib/Elastic/Model/TypeMap/Base.pm
@@ -263,15 +263,7 @@ sub class_mapping {
# return $handler->(@_);
# }
- my ($wrapper);
- if ( does_role( $class, 'Elastic::Model::Meta::Class::Doc' ) ) {
- $wrapper = $class;
- $class = $wrapper->meta->original_class;
- }
- else {
- $wrapper = $map->model->class_for($class);
- }
- $attrs ||= $map->indexable_attrs( $wrapper || $class );
+ $attrs ||= $map->indexable_attrs( $class );
my %props = map { $_ => $map->attribute_mapping( $attrs->{$_} ) }
keys %$attrs;
@@ -344,9 +336,11 @@ sub _has_type {
#===================================
sub indexable_attrs {
#===================================
- my $self = shift;
+ my $map = shift;
my $class = shift;
- my $meta = $class->meta;
+ $class = $map->model->class_for($class) || $class;
+ my $meta = $class->meta;
+
return {
map { $_->name => $_ }
grep { !$_->exclude } $meta->get_all_attributes
View
12 lib/Elastic/Model/TypeMap/Objects.pm
@@ -130,31 +130,29 @@ sub _map_class {
sub _class_attrs {
#===================================
my ( $map, $class, $attr ) = @_;
+
+ $class = $map->model->class_for($class) || $class;
my $meta = $class->meta;
return { map { $_->name => $_ } $meta->get_all_attributes }
- unless does_role( $meta, 'Elastic::Model::Meta::Class::DocType' );
+ unless does_role( $meta, 'Elastic::Model::Meta::Class::Doc' );
my %attrs;
- my $wrapper = $map->model->class_for($class);
- my $wrapper_meta = $wrapper ? $wrapper->meta : $meta;
-
my $inc = $attr->include_attrs;
my $exc = $attr->exclude_attrs;
my @inc_attr = $inc
? map {
- $wrapper_meta->find_attribute_by_name($_)
+ $meta->find_attribute_by_name($_)
or die "Unknown attribute ($_) in class $class"
} @$inc
: $meta->get_all_attributes;
%attrs = map { $_->name => $_ } grep { !$_->exclude } @inc_attr;
delete @attrs{@$exc} if $exc;
- $attrs{uid} = $wrapper_meta->find_attribute_by_name('uid')
- if $wrapper;
+ $attrs{uid} = $meta->find_attribute_by_name('uid');
return \%attrs;
}

0 comments on commit b6f7919

Please sign in to comment.