Sha256: 836d3ece0ca08331a96eb5fb3a1a335b5687fdbacdec99274bbad351e88177dc

Contents?: true

Size: 959 Bytes

Versions: 10

Compression:

Stored size: 959 Bytes

Contents

class Label
  include Mongoid::Document
  include Mongoid::Timestamps::Updated::Short

  field :name, type: String
  field :after_create_called, type: Mongoid::Boolean, default: false
  field :after_save_called, type: Mongoid::Boolean, default: false
  field :after_update_called, type: Mongoid::Boolean, default: false
  field :after_validation_called, type: Mongoid::Boolean, default: false

  embedded_in :artist
  embedded_in :band

  after_create :after_create_stub
  after_save :after_save_stub
  after_update :after_update_stub
  after_validation :after_validation_stub
  before_validation :cleanup

  def after_create_stub
    self.after_create_called = true
  end

  def after_save_stub
    self.after_save_called = true
  end

  def after_update_stub
    self.after_update_called = true
  end

  def after_validation_stub
    self.after_validation_called = true
  end

  private
  def cleanup
    self.name = self.name.downcase.capitalize
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mongoid-4.0.2/spec/app/models/label.rb
mongoid-4.0.2 spec/app/models/label.rb
mongoid-4.0.1 spec/app/models/label.rb
mongoid-4.0.0 spec/app/models/label.rb
mongoid-4.0.0.rc2 spec/app/models/label.rb
mongoid-4.0.0.rc1 spec/app/models/label.rb
mongoid-4.0.0.beta2 spec/app/models/label.rb
mongoid-4.0.0.beta1 spec/app/models/label.rb
mongoid-4.0.0.alpha2 spec/app/models/label.rb
mongoid-4.0.0.alpha1 spec/app/models/label.rb