File tree 2 files changed +13
-15
lines changed
2 files changed +13
-15
lines changed Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
15
15
module Mongoid ::Taggable
16
- def self . included ( base )
17
- # create fields for tags and index it
18
- base . field :tags_array , :type => Array
19
- base . index [ [ ' tags_array' , Mongo :: ASCENDING ] ]
20
-
21
- # add callback to save tags index
22
- base . after_save do |document |
16
+ extend ActiveSupport :: Concern
17
+
18
+ included do
19
+ field : tags_array, :type => Array
20
+ index [ [ 'tags_array' , Mongo :: ASCENDING ] ]
21
+
22
+ set_callback :save , :after do |document |
23
23
document . class . save_tags_index!
24
24
end
25
-
26
- # extend model
27
- base . extend ClassMethods
28
- base . send :include , InstanceMethods
29
-
30
- # enable indexing as default
31
- base . enable_tags_index!
25
+
26
+ # enable tag weight indexing as default
27
+ enable_tags_index!
32
28
end
33
-
29
+
34
30
module ClassMethods
35
31
# get an array with all defined tags for this model, this list returns
36
32
# an array of distinct ordered list of tags defined in all documents
Original file line number Diff line number Diff line change
1
+ require 'active_support/concern'
2
+
1
3
require File . join ( File . dirname ( __FILE__ ) , 'mongoid/taggable' )
You can’t perform that action at this time.
0 commit comments