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

Defined in:
lib/sequel/plugins/composition.rb

Instance Method Summary collapse

Instance Method Details

#before_validationObject

For each composition, set the columns in the model class based on the composition object.



173
174
175
176
# File 'lib/sequel/plugins/composition.rb', line 173

def before_validation
  @compositions.keys.each{|n| instance_exec(&model.compositions[n][:decomposer])} if @compositions
  super
end

#compositionsObject

Cache of composition objects for this class.



161
162
163
# File 'lib/sequel/plugins/composition.rb', line 161

def compositions
  @compositions ||= {}
end

#freezeObject

Freeze compositions hash when freezing model instance.



166
167
168
169
# File 'lib/sequel/plugins/composition.rb', line 166

def freeze
  compositions.freeze
  super
end