class Person
include Mongoid::Document
include Mongoid::Taggable
field :foo, type: String
# taggable stays basically the same as 1.1.1
taggable # :tags
taggable :interests, separator: ','
taggable :skills
# new taggregation method to define aggregation rules
taggregation :tags
taggregation :interests, :tags, strategy: Mongoid::Taggable::Strategy::RealTime, group_by: :foo
taggregation :tags, strategy: CustomMapReduce, group_by: :foo, scope: -->{ any_in(status: :active) }, name: "active_%{context}"
end
As part of this change, the aggregation strategies will now become classes (currently they are modules). They must inherit the Strategy class which provides a base API for creating rules.
# custom strategies are now possible
class CustomMapReduce < Mongoid::Taggable::Strategy
def tags
# must be implemented
end
def tags_with_weight
# must be implemented
end
end
One change, from 2.0.0 I'd like to use the following shorter namespaces:
Mongoid::Taggable # this is only one that needs to be included in the Model.
Mongoid::Taggable::Aggregation
Mongoid::Taggable::Strategy
@lgs I'm working on a version 2.0.0 of this gem.
It will allow you do this:
As part of this change, the aggregation strategies will now become classes (currently they are modules). They must inherit the
Strategy
class which provides a base API for creating rules.One change, from 2.0.0 I'd like to use the following shorter namespaces:
Code is 70% done.