NAME

ElasticSearchX::Model::Document::Trait::Class - Trait that extends the meta class of a document class

VERSION

version 2.0.1

ATTRIBUTES

set_class

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.

A custum set class (e.g. MyModel::Tweet::Set) must inherit from ElasticSearchX::Model::Document::Set.

short_name

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.

METHODS

mapping

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.

add_property

$meta->add_property( name => ( is => 'ro', isa => 'Str' ) )

Add a property through the $meta object.

all_properties_loaded

Returns true if all properties were acutally loaded from storage or whether ElasticSearchX::Model::Set/fields was used to return a partial result set.

get_id_attribute

Get the id attribute, i.e. the attribute that has the id option set. Returns undef if it doesn't exist.

get_parent_attribute

Get the parent attribute, i.e. the attribute that has the parent option set. Returns undef if it doesn't exist.

get_all_properties

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.

Since this method is called quite often, the result is cached if the document class is immutable.

get_data

"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).

AUTHOR

Moritz Onken

COPYRIGHT AND LICENSE

This software is Copyright (c) 2019 by Moritz Onken.

This is free software, licensed under:

The (three-clause) BSD License