Sha256: 6d2e4e631e03d4b7a9c9b4922ca065172853deee528f1dd5ada53a3f6b64bdf4

Contents?: true

Size: 371 Bytes

Versions: 4

Compression:

Stored size: 371 Bytes

Contents

require 'mongoid'
require 'mongoid_countercache'

class Comment
  include Mongoid::Document
  include Mongoid::CounterCache

  belongs_to :post

  field :mark, :type => Integer, :default => 5

  counter_cache :post, :variants => {
    :positive => lambda { mark > 8},
    :negative => lambda { mark < 3}
  }

  counter_cache :post, :field_name => 'custom_field_name'
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mongoid_countercache-1.0.0.mongoidalpha1 spec/models/comment.rb
mongoid_countercache-0.0.3 spec/models/comment.rb
mongoid_countercache-0.0.2 spec/models/comment.rb
mongoid_countercache-0.0.1 spec/models/comment.rb