Single table inheritance. You have a class,
Document, stored in the
documents (I
know) table you have:
package Review
use Moose
extends 'Document'
The documents table has a set of columns which is the superset of attributes of Document and all its subclass and a
type column which contains the name of the class for that row.
Document->find finds Documents, Reviews and any other subclasses of document,
Review->find finds only reviews (and any subclasses).
Composed of: A way of getting round primitive obsession. You can declare something like:
composed_of :price,
:class_name => 'Money',
:mapping => %w{cents currency}
And ActiveRecord handles turning cents and currency columns into a Money object when the object is pulled out of the database breaking the price into cents and currency the the object's put back in there.
Bells and whistles: Mostly to do with declaring relationships between classes with has_many/belongs_to etc. If you want me to regurgitate the ActiveRecord::Base documentation then I will, but it's far from being the world's best documentation in the first place and my paraphrasing skills are poor. Most of the perly ORMs appear to have sensible equivalents already so it won't be beyond my wit to sort out the mapping.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link or
or How to display code and escape characters
are good places to start.