Sha256: cd1675eaf35656d175bb3d45def90487cdaae4107daffc7d8494de1bf1f23fab

Contents?: true

Size: 1.08 KB

Versions: 59

Compression:

Stored size: 1.08 KB

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

  field :before_save_count, type: Integer, default: 0

  embedded_in :artist
  embedded_in :band

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

  def before_save_stub
    self.before_save_count += 1
  end

  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

59 entries across 55 versions & 3 rubygems

Version Path
mongoid-6.0.1 spec/app/models/label.rb
mongoid-5.1.5 spec/app/models/label.rb
mongoid-6.0.0 spec/app/models/label.rb
mongoid-5.1.4 spec/app/models/label.rb
mongoid-6.0.0.rc0 spec/app/models/label.rb
mongoid-6.0.0.beta spec/app/models/label.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mongoid-5.1.3/spec/app/models/label.rb
mongoid-5.1.3 spec/app/models/label.rb
mongoid-5.1.2 spec/app/models/label.rb
mongoid-5.1.1 spec/app/models/label.rb
mongoid-5.1.0 spec/app/models/label.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/mongoid-5.0.2/spec/app/models/label.rb
tdiary-4.2.1 vendor/bundle/ruby/2.3.0/gems/mongoid-5.0.2/spec/app/models/label.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/mongoid-5.0.1/spec/app/models/label.rb
mongoid-5.0.2 spec/app/models/label.rb
mongoid-5.0.1 spec/app/models/label.rb
mongoid-5.0.0 spec/app/models/label.rb
mongoid-5.0.0.rc0 spec/app/models/label.rb
mongoid-5.0.0.beta spec/app/models/label.rb