Using the Scoring Interface

Movable Type comes with a scoring framework built in. What does that mean? It means that a developer can very easily bootstrap any object/class/package they define to expose methods to allow for plugins to score, both positively and negatively that object.

Inheriting from the Scorable Interface

To make an object scorable, a developer need only state that their package inherits from the MT::Scorable interface.

 package My::Object::Model;
 use base qw( MT::Object MT::Scorable );

 __PACKAGE__->install_properties({
     # ...
 });

 1;

Using the MT::Scorable Interface

Then you get the methods in the Scorable interface on your model objects:

 sub score_myobject {
     my ($m_id) = @_;
     my $m = My::Object::Model->load($m_id);

     my $is_awesome = $m->score_avg('percent-rating') > 80 ? 1 : 0;

     if ($is_awesome) {
         # do something wicked
     }
 }

See Also

This page was last updated on 2008-04-15, 10:01.  

Leave a note

Have a question, please use the MT Forums. Notes sumbitted here should pertain to tips & hints regarding documentation.