The composition plugin allows you to easily define getter and setter instance methods for a class where the backing data is composed of other getters and decomposed to other setters.
A simple example of this is when you have a database table with separate columns for year, month, and day, but where you want to deal with Date objects in your ruby code. This can be handled with:
Album.plugin :composition Album.composition :date, :mapping=>[:year, :month, :day]
The :mapping option is optional, but you can define custom composition and decomposition procs via the :composer and :decomposer options.
Note that when using the composition object, you should not modify the underlying columns if you are also instantiating the composition, as otherwise the composition object values will override any underlying columns when the object is saved.
Generated with the Darkfish Rdoc Generator 2.