Sha256: 41373d2ba01dce67d571a4637a6cd6b2825a3f862301dbd56d62ec3ed49e07c2
Contents?: true
Size: 806 Bytes
Versions: 3
Compression:
Stored size: 806 Bytes
Contents
module MongoidExt module Tags def self.included(klass) klass.class_eval do extend ClassMethods field :tags, :type => Array, :index => true, :default => [] end end module ClassMethods def tag_cloud(conditions = {}, limit = 30) self.db.nolock_eval("function(collection, q,l) { return tag_cloud(collection, q,l); }", self.collection_name, conditions, limit) end # Model.find_with_tags("budget", "big").limit(4) def find_with_tags(*tags) self.all(:conditions => {:tags.in => tags}) end def find_tags(regex, conditions = {}, limit = 30) self.db.nolock_eval("function(collection, a,b,c) { return find_tags(collection, a,b,c); }", self.collection_name, regex, conditions, limit) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mongoid_ext-0.7.1 | lib/mongoid_ext/tags.rb |
mongoid_ext-0.6.2 | lib/mongoid_ext/tags.rb |
mongoid_ext-0.6.1 | lib/mongoid_ext/tags.rb |