ElasticSearchX::Model::Document::Trait::Class - Trait that extends the meta class of a document class
version 0.1.7
A call to $index->type('tweet') returns an instance of set_class. Given a document class MyModel::Tweet, the builder of this attribute tries to find a class named MyModel::Tweet::Set. If it's not found, the default class ElasticSearchX::Model::Document::Set is used.
$index->type('tweet')
set_class
MyModel::Tweet
MyModel::Tweet::Set
A custum set class (e.g. MyModel::Tweet::Set) must inherit from ElasticSearchX::Model::Document::Set.
MyClass::Tweet->meta->short_name; # tweet
The short_name is used as name for the type. It defaults to the lowercased, last segment of the class name.
short_name
my $mapping = $document->meta->mapping;
Builds the type mapping for this document class. It loads all properties using "get_all_properties" and calls "build_property" in ElasticSearchX::Model::Document::Trait::Attribute.
$meta->add_property( name => ( is => 'ro', isa => 'Str' ) )
Add a property through the $meta object.
$meta
Returns true if all properties were acutally loaded from storage or whether ElasticSearchX::Model::Set/fields was used to return a partial result set.
ElasticSearchX::Model::Set/fields
Get the id attribute, i.e. the attribute that has the id option set. Returns undef if it doesn't exist.
id
Get the parent attribute, i.e. the attribute that has the parent option set. Returns undef if it doesn't exist.
parent
Returns a list of all properties in the document class. An attribute is considered a property, if it does the ElasticSearchX::Model::Document::Trait::Attribute role. That means all attributes that don't have the property option explicitly set to 0.
property
0
Since this method is called quite often, the result is cached if the document class is immutable.
"put" in ElasticSearchX::Model::Document calls this method to get an HashRef of all properties and their values. Values are deflated if a deflator was specified (e.g. DateTime objects are deflated to an ISO8601 string).
Moritz Onken
This software is Copyright (c) 2013 by Moritz Onken.
This is free software, licensed under:
The (three-clause) BSD License
To install ElasticSearchX::Model, copy and paste the appropriate command in to your terminal.
cpanm
cpanm ElasticSearchX::Model
CPAN shell
perl -MCPAN -e shell install ElasticSearchX::Model
For more information on module installation, please visit the detailed CPAN module installation guide.