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

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) before_save

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



154
155
156
157
# File 'lib/sequel/plugins/composition.rb', line 154

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

- (Object) compositions

Cache of composition objects for this class.



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

def compositions
  @compositions ||= {}
end

- (Object) dup

Duplicate compositions hash when duplicating model instance.



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

def dup
  s = self
  super.instance_eval do
    @compositions = s.compositions.dup
    self
  end
end

- (Object) freeze

Freeze compositions hash when freezing model instance.



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

def freeze
  compositions.freeze
  super
end