Skip to content

Instantly share code, notes, and snippets.

@andrefs
Created December 3, 2012 15:58
Show Gist options
  • Save andrefs/4195924 to your computer and use it in GitHub Desktop.
Save andrefs/4195924 to your computer and use it in GitHub Desktop.
Moose type unions in Elastic::Model
package MyApp;
use Elastic::Model;
has_namespace 'myapp' => {
user => 'MyApp::User',
};
package Class1;
use Moose;
package Class2;
use Moose;
package MyApp::User;
use Elastic::Doc;
has 'attr' => (is => 'rw', isa => 'Class1|Class2');
package main;
my $model = MyApp->new;
my $esdomain = $model->domain('myapp');
$esdomain->create(
'user' => {
attr => Class1->new,
});
__END__
No deflator found for attribute (name) in class MyApp::User at /home/andrefs/.perl5/perls/perl-5.16.2/lib/site_perl/5.16.2/Elastic/Model/TypeMap/Base.pm line 66.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment