Sha256: 19162c0eefacb3cecee632c29e4d3e080584f04d0518b83541bc1d2f64b1569b
Contents?: true
Size: 888 Bytes
Versions: 5
Compression:
Stored size: 888 Bytes
Contents
class Artist include Mongoid::Document field :name embeds_many :songs embeds_many :labels before_create :before_create_stub after_create :create_songs protected def before_create_stub true end def create_songs 2.times { |n| songs.create!(:title => "#{n}") } end end class Song include Mongoid::Document field :title embedded_in :artist, :inverse_of => :songs end class Label include Mongoid::Document field :name embedded_in :artist, :inverse_of => :labels before_validation :cleanup private def cleanup self.name = self.name.downcase.capitalize end end class ValidationCallback include Mongoid::Document field :history, :type => Array, :default => [] validate do self.history << :validate end before_validation { self.history << :before_validation } after_validation { self.history << :after_validation } end
Version data entries
5 entries across 5 versions & 2 rubygems