Module | Sequel::Plugins::Composition
In: | lib/sequel/plugins/composition.rb

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.

### Methods

apply

### Classes and Modules

Module Sequel::Plugins::Composition::ClassMethods
Module Sequel::Plugins::Composition::InstanceMethods

### Public Class methods

apply(model)

Define the necessary class instance variables.

[Source]

        # File lib/sequel/plugins/composition.rb, line 25
    25:       def self.apply(model)
    26:         model.instance_eval{@compositions = {}}
    27:       end

[Validate]