Created
December 3, 2012 15:58
-
-
Save andrefs/4195924 to your computer and use it in GitHub Desktop.
Moose type unions in Elastic::Model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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