acts-as-taggable-on-mongoid 6.0.1.5 → 6.1.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +2 -1
  3. data/.rubocop.yml +8 -10
  4. data/.ruby-version +1 -1
  5. data/Gemfile.lock +76 -82
  6. data/README.md +102 -28
  7. data/acts-as-taggable-on-mongoid.gemspec +3 -4
  8. data/lib/acts-as-taggable-on-mongoid.rb +9 -3
  9. data/lib/acts_as_taggable_on_mongoid/models/concerns/tag_associations.rb +12 -0
  10. data/lib/acts_as_taggable_on_mongoid/models/concerns/tag_fields.rb +4 -1
  11. data/lib/acts_as_taggable_on_mongoid/models/concerns/tag_methods.rb +21 -12
  12. data/lib/acts_as_taggable_on_mongoid/models/concerns/tag_migration.rb +46 -0
  13. data/lib/acts_as_taggable_on_mongoid/models/concerns/tag_scopes.rb +3 -2
  14. data/lib/acts_as_taggable_on_mongoid/models/concerns/tag_validations.rb +1 -1
  15. data/lib/acts_as_taggable_on_mongoid/models/concerns/tagging_associations.rb +13 -1
  16. data/lib/acts_as_taggable_on_mongoid/models/concerns/tagging_fields.rb +4 -2
  17. data/lib/acts_as_taggable_on_mongoid/models/concerns/tagging_methods.rb +2 -2
  18. data/lib/acts_as_taggable_on_mongoid/models/concerns/tagging_migration.rb +46 -0
  19. data/lib/acts_as_taggable_on_mongoid/models/concerns/tagging_scopes.rb +7 -5
  20. data/lib/acts_as_taggable_on_mongoid/models/concerns/tagging_validations.rb +2 -6
  21. data/lib/acts_as_taggable_on_mongoid/tag_list.rb +91 -4
  22. data/lib/acts_as_taggable_on_mongoid/taggable.rb +13 -1
  23. data/lib/acts_as_taggable_on_mongoid/taggable/changeable.rb +5 -4
  24. data/lib/acts_as_taggable_on_mongoid/taggable/core.rb +156 -34
  25. data/lib/acts_as_taggable_on_mongoid/taggable/tag_type_definition.rb +29 -50
  26. data/lib/acts_as_taggable_on_mongoid/taggable/tag_type_definition/attributes.rb +57 -6
  27. data/lib/acts_as_taggable_on_mongoid/taggable/tag_type_definition/changeable.rb +52 -39
  28. data/lib/acts_as_taggable_on_mongoid/taggable/tag_type_definition/list_methods.rb +77 -0
  29. data/lib/acts_as_taggable_on_mongoid/taggable/tag_type_definition/names.rb +12 -0
  30. data/lib/acts_as_taggable_on_mongoid/taggable/tagged_with_query/all_tags_query.rb +1 -1
  31. data/lib/acts_as_taggable_on_mongoid/taggable/tagged_with_query/any_tags_query.rb +1 -1
  32. data/lib/acts_as_taggable_on_mongoid/taggable/tagged_with_query/exclude_tags_query.rb +1 -1
  33. data/lib/acts_as_taggable_on_mongoid/taggable/tagged_with_query/match_all_tags_query.rb +1 -1
  34. data/lib/acts_as_taggable_on_mongoid/taggable/tagger_relation.rb +53 -0
  35. data/lib/acts_as_taggable_on_mongoid/taggable/utils/tag_list_diff.rb +9 -7
  36. data/lib/acts_as_taggable_on_mongoid/tagger.rb +67 -0
  37. data/lib/acts_as_taggable_on_mongoid/tagger/tag_methods.rb +74 -0
  38. data/lib/acts_as_taggable_on_mongoid/tagger_tag_list.rb +171 -0
  39. data/lib/acts_as_taggable_on_mongoid/version.rb +1 -1
  40. metadata +18 -26
@@ -34,6 +34,18 @@ module ActsAsTaggableOnMongoid
34
34
  # can be used. If custom options like `parse` or `parser` are to be used for the default, the value
35
35
  # must be passed in as an array with a hash as the last value. Like list setters, parsing is assumed.
36
36
  # Example: default: ["this, is, a, list", parser: ActsAsTaggableOnMongoid::GenericParser]
37
+ # * tagger
38
+ # Multiple variants
39
+ #
40
+ # true - If simply the value `true`, the tag list supports owners. No default owner will be used when
41
+ # setting or accessing tag_lists
42
+ # Hash - A hash of values defining default options for the tag list:
43
+ # * default_tagger
44
+ # A symbol of a method on the taggable object that owns the HashList which is used to determine
45
+ # the default owner for a list if an owner is not specified.
46
+ # * tag_list_uses_default_tagger
47
+ # true/false indicating if a non-owner method that returns a tag_list should assume the default_tagger
48
+ # or return items with no owner.
37
49
 
38
50
  ##
39
51
  # This is an alias for calling <tt>acts_as_taggable_on :tags</tt>.
@@ -111,8 +123,8 @@ module ActsAsTaggableOnMongoid
111
123
  ActsAsTaggableOnMongoid::Taggable::TaggedWith,
112
124
  # include Collection - not sure we will need as done here. Need to think more on this one.
113
125
  # include Cache - TODO: Add this.
114
- # include Ownership - TODO: Add this.
115
126
  # include Related - TODO: Add this.
127
+ ActsAsTaggableOnMongoid::Taggable::TaggerRelation,
116
128
  ActsAsTaggableOnMongoid::Taggable::ListTags].each do |include_module|
117
129
  include include_module unless included_modules.include?(include_module)
118
130
  end
@@ -40,9 +40,9 @@ module ActsAsTaggableOnMongoid
40
40
  tag_types.each_value do |tag_definition|
41
41
  tag_list_name = tag_definition.tag_list_name
42
42
 
43
- next unless changed_attributes.key? tag_list_name
43
+ next unless public_send("#{tag_list_name}_changed?")
44
44
 
45
- changed_values[tag_list_name] = [changed_attributes[tag_list_name], public_send(tag_list_name)]
45
+ changed_values[tag_list_name] = public_send("#{tag_list_name}_change")
46
46
  end
47
47
 
48
48
  changed_values
@@ -60,11 +60,12 @@ module ActsAsTaggableOnMongoid
60
60
  private
61
61
 
62
62
  def attribute_will_change!(attribute_name)
63
- return super if tag_types.none? { |_tag_name, tag_definition| tag_definition.tag_list_name.to_s == attribute_name.to_s }
63
+ tag_definition = tag_types.detect { |_tag_name, tag_def| tag_def.tag_list_name.to_s == attribute_name.to_s }&.last
64
+ return super if tag_definition.blank?
64
65
 
65
66
  return if changed_attributes.key?(attribute_name)
66
67
 
67
- changed_attributes[attribute_name] = public_send(attribute_name)&.dup
68
+ changed_attributes[attribute_name] = tag_list_cache_on(tag_definition)&.dup
68
69
  end
69
70
  end
70
71
  end
@@ -40,14 +40,99 @@ module ActsAsTaggableOnMongoid
40
40
  end
41
41
  end
42
42
 
43
- def apply_pre_processed_defaults
44
- super
43
+ def apply_post_processed_defaults
44
+ defaults = super
45
45
 
46
- set_tag_list_defaults
46
+ defaults |= set_tag_list_defaults
47
+
48
+ defaults
47
49
  end
48
50
 
49
51
  private
50
52
 
53
+ def set_tag_list(tag_definition, new_tags)
54
+ dup_tags = Array.wrap(new_tags).dup
55
+ options = dup_tags.extract_options!.dup
56
+ options[:parse] = options.fetch(:parse) { true }
57
+
58
+ new_list = tag_definition.parse(*dup_tags, options)
59
+ new_list.taggable = self
60
+ new_list.tagger = tag_definition.tag_list_default_tagger(self) unless options.key?(:tagger)
61
+
62
+ mark_tag_list_changed(new_list)
63
+ tag_list_set(new_list)
64
+ end
65
+
66
+ def get_tag_list_change(tag_definition)
67
+ tag_list_name = tag_definition.tag_list_name
68
+
69
+ return nil unless public_send("#{tag_list_name}_changed?")
70
+
71
+ changed_value = new_record? ? tag_definition.default_tagger_tag_list(self) : changed_attributes[tag_list_name]
72
+ current_value = tag_list_cache_on(tag_definition)
73
+
74
+ return nil if (changed_value <=> current_value)&.zero?
75
+
76
+ tag_list_change_value(tag_definition, changed_value, current_value)
77
+ end
78
+
79
+ def tag_list_change_value(tag_definition, changed_value, current_value)
80
+ if tag_definition.tagger?
81
+ [changed_value.dup, current_value.dup]
82
+ else
83
+ [changed_value[nil].dup, current_value[nil].dup]
84
+ end
85
+ end
86
+
87
+ def get_tag_list_changed(tag_definition)
88
+ tag_list_name = tag_definition.tag_list_name
89
+
90
+ return false unless changed_attributes.key?(tag_list_name)
91
+
92
+ changed_value = new_record? ? tag_definition.default_tagger_tag_list(self) : changed_attributes[tag_list_name]
93
+ current_value = tag_list_cache_on(tag_definition)
94
+
95
+ !(changed_value <=> current_value)&.zero?
96
+ end
97
+
98
+ def get_tag_list_was(tag_definition)
99
+ default_tagger = tag_definition.tag_list_default_tagger(self)
100
+ return tag_definition.default_tagger_tag_list(self)[default_tagger].dup if new_record?
101
+
102
+ tag_list_name = tag_definition.tag_list_name
103
+
104
+ if public_send "#{tag_list_name}_changed?"
105
+ changed_attributes[tag_list_name][default_tagger].dup
106
+ else
107
+ public_send(tag_list_name).dup
108
+ end
109
+ end
110
+
111
+ def get_tag_lists_was(tag_definition)
112
+ return tag_definition.default_tagger_tag_list(self).dup if new_record?
113
+
114
+ tag_list_name = tag_definition.tag_list_name
115
+
116
+ if public_send "#{tag_list_name}_changed?"
117
+ changed_attributes[tag_list_name].dup
118
+ else
119
+ public_send(tag_definition.tagger_tag_lists_name).dup
120
+ end
121
+ end
122
+
123
+ def get_tagger_list_was(tag_definition, tagger)
124
+ return nil unless tag_definition.tagger?
125
+ return tag_definition.default_tagger_tag_list(self)[tagger].dup if new_record?
126
+
127
+ tag_list_name = tag_definition.tag_list_name
128
+
129
+ if public_send "#{tag_list_name}_changed?"
130
+ changed_attributes[tag_list_name][tagger].dup
131
+ else
132
+ public_send(tag_definition.tagger_tag_list_name, tagger).dup
133
+ end
134
+ end
135
+
51
136
  def tag_list_cache_set_on(tag_definition)
52
137
  variable_name = tag_definition.tag_list_variable_name
53
138
 
@@ -66,35 +151,57 @@ module ActsAsTaggableOnMongoid
66
151
  # end
67
152
 
68
153
  instance_variable_get(variable_name) ||
69
- tag_list_set(ActsAsTaggableOnMongoid::TagList.new(tag_definition, tags_on(tag_definition).map(&:tag_name)))
154
+ tagger_tag_list_set(tagger_tag_list_from_taggings(tag_definition, all_tags_on(tag_definition)))
155
+ end
156
+
157
+ def tagger_tag_list_from_taggings(tag_definition, taggings)
158
+ tagger_tag_list = ActsAsTaggableOnMongoid::TaggerTagList.new(tag_definition, self)
159
+
160
+ taggings.each do |tagging|
161
+ tagger_tag_list[tagging.tagger].silent_concat [tagging.tag_name]
162
+ end
163
+
164
+ tagger_tag_list
70
165
  end
71
166
 
72
167
  def tag_list_on(tag_definition)
73
168
  # add_custom_context(tag_definition)
74
169
 
75
- tag_list_cache_on(tag_definition)
170
+ tag_list_cache_on(tag_definition)[tag_definition.tag_list_default_tagger(self)]
76
171
  end
77
172
 
78
173
  def all_tags_list_on(tag_definition)
79
- variable_name = tag_definition.all_tag_list_variable_name
80
- cached_variable = instance_variable_get(variable_name)
81
-
82
- return cached_variable if instance_variable_defined?(variable_name) && cached_variable
83
-
84
- instance_variable_set(variable_name, ActsAsTaggableOnMongoid::TagList.new(tag_definition, all_tags_on(tag_definition).map(&:name)).freeze)
174
+ tag_list_on(tag_definition).flatten
85
175
  end
86
176
 
87
177
  ##
88
178
  # Returns all tags of a given context
89
179
  def all_tags_on(tag_definition)
90
- tag_definition.tags_table.for_tag(tag_definition).to_a
180
+ scope = public_send(tag_definition.taggings_name).where(context: tag_definition.tag_type)
181
+
182
+ # when preserving tag order, return tags in created order
183
+ # if we added the order to the association this would always apply
184
+ scope = scope.order_by(*tag_definition.taggings_order) if tag_definition.preserve_tag_order?
185
+
186
+ scope
91
187
  end
92
188
 
93
189
  ##
94
190
  # Returns all tags that are not owned of a given context
95
191
  def tags_on(tag_definition)
96
- # scope = public_send(tag_definition.taggings_name).where(context: tag_definition.tag_type, tagger_id: nil)
97
- scope = public_send(tag_definition.taggings_name).where(context: tag_definition.tag_type)
192
+ scope = public_send(tag_definition.taggings_name).where(context: tag_definition.tag_type, :tagger_id.exists => false)
193
+
194
+ # when preserving tag order, return tags in created order
195
+ # if we added the order to the association this would always apply
196
+ scope = scope.order_by(*tag_definition.taggings_order) if tag_definition.preserve_tag_order?
197
+
198
+ scope
199
+ end
200
+
201
+ ##
202
+ # Returns all tags that are owned by a given tagger of a given context
203
+ def tagger_tags_on(tagger, tag_definition)
204
+ scope = public_send(tag_definition.taggings_name).where(context: tag_definition.tag_type, tagger: tagger)
98
205
 
99
206
  # when preserving tag order, return tags in created order
100
207
  # if we added the order to the association this would always apply
@@ -105,41 +212,56 @@ module ActsAsTaggableOnMongoid
105
212
 
106
213
  def mark_tag_list_changed(new_list)
107
214
  tag_definition = new_list.tag_definition
108
- current_tag_list = public_send(tag_definition.tag_list_name)
215
+ current_tag_list = tag_list_cache_on(tag_definition)
109
216
 
110
- if (tag_definition.preserve_tag_order? && new_list != current_tag_list) ||
111
- new_list.sort != current_tag_list.sort
112
- current_tag_list.notify_will_change
113
- end
217
+ return if current_tag_list == new_list
218
+
219
+ current_tag_list.notify_will_change
220
+ end
221
+
222
+ def tagger_tag_list_set(new_list)
223
+ instance_variable_set(new_list.tag_definition.tag_list_variable_name, new_list)
114
224
  end
115
225
 
116
226
  def tag_list_set(new_list)
117
227
  # add_custom_context(tag_definition, owner)
118
228
 
119
229
  new_list.taggable = self
230
+ tag_definition = new_list.tag_definition
231
+ tagger_tag_list = ActsAsTaggableOnMongoid::TaggerTagList.new(tag_definition, self)
120
232
 
121
- instance_variable_set(new_list.tag_definition.tag_list_variable_name, new_list)
233
+ tagger_tag_list[new_list.tagger] = new_list
234
+
235
+ instance_variable_set(tag_definition.tag_list_variable_name, tagger_tag_list)
122
236
  end
123
237
 
124
238
  ##
125
239
  # Find existing tags or create non-existing tags
126
- def load_tags(tag_definition, tag_list)
127
- tag_definition.tags_table.find_or_create_all_with_like_by_name(tag_definition, tag_list)
240
+ def load_tags(tag_definition, tagger_tag_list)
241
+ tag_definition.tags_table.find_or_create_tagger_list_with_like_by_name(tag_definition, tagger_tag_list)
128
242
  end
129
243
 
130
244
  def set_tag_list_defaults
131
- return unless new_record?
245
+ return [] unless new_record?
132
246
 
247
+ defaulted_values = []
133
248
  tag_types.each_value do |tag_definition|
134
- default = tag_definition.default
249
+ next if instance_variable_defined?(tag_definition.tag_list_variable_name)
250
+
251
+ default = tag_definition.taggable_default(self)
135
252
  next unless default.present?
136
253
 
137
- tag_list_name = tag_definition.tag_list_name
138
- next if public_send(tag_list_name).present?
254
+ set_default_value(tag_definition, default)
139
255
 
140
- public_send("#{tag_list_name}=", default)
141
- changed_attributes.delete tag_list_name
256
+ defaulted_values << tag_definition.tag_list_name
142
257
  end
258
+
259
+ defaulted_values
260
+ end
261
+
262
+ def set_default_value(tag_definition, default)
263
+ public_send(tag_definition.tagger_tag_lists_name)[default.tagger] = default
264
+ changed_attributes.delete tag_definition.tag_list_name
143
265
  end
144
266
 
145
267
  def save_tags
@@ -167,11 +289,11 @@ module ActsAsTaggableOnMongoid
167
289
  end
168
290
 
169
291
  def extract_tag_list_changes(tag_definition)
170
- tag_list = tag_list_cache_on(tag_definition).uniq
292
+ tag_list = tag_list_cache_on(tag_definition)
171
293
 
172
294
  # Find existing tags or create non-existing tags:
173
295
  tags = find_or_create_tags_from_list_with_context(tag_definition, tag_list)
174
- current_tags = tags_on(tag_definition).map(&:tag).compact
296
+ current_tags = all_tags_on(tag_definition)
175
297
 
176
298
  tag_list_diff = ActsAsTaggableOnMongoid::Taggable::Utils::TagListDiff.new tag_definition: tag_definition,
177
299
  tags: tags,
@@ -210,10 +332,10 @@ module ActsAsTaggableOnMongoid
210
332
  # end
211
333
  # end
212
334
  #
213
- # @param [Array<String>] tag_list Tags to find or create
214
- # @param [Symbol] context The tag context for the tag_list
215
- def find_or_create_tags_from_list_with_context(tag_definition, tag_list)
216
- load_tags(tag_definition, tag_list)
335
+ # @param [Array<String>] tagger_tag_list Tags to find or create grouped by tagger
336
+ # @param [Symbol] tag_definition The tag context for the tag_list
337
+ def find_or_create_tags_from_list_with_context(tag_definition, tagger_tag_list)
338
+ load_tags(tag_definition, tagger_tag_list)
217
339
  end
218
340
  end
219
341
  end
@@ -13,27 +13,20 @@ module ActsAsTaggableOnMongoid
13
13
  attr_reader :owner,
14
14
  :tag_type
15
15
 
16
+ include ActsAsTaggableOnMongoid::Taggable::TagTypeDefinition::ListMethods
16
17
  include ActsAsTaggableOnMongoid::Taggable::TagTypeDefinition::Attributes
17
18
  include ActsAsTaggableOnMongoid::Taggable::TagTypeDefinition::Names
18
19
  include ActsAsTaggableOnMongoid::Taggable::TagTypeDefinition::Changeable
19
20
 
20
21
  def initialize(owner, tag_type, options = {})
21
- options = options.dup
22
+ options = ActsAsTaggableOnMongoid::Taggable::TagTypeDefinition.extract_tag_definition_options(options)
22
23
 
23
- options.assert_valid_keys(:parser,
24
- :preserve_tag_order,
25
- :cached_in_model,
26
- :force_lowercase,
27
- :force_parameterize,
28
- :remove_unused_tags,
29
- :tags_table,
30
- :taggings_table,
31
- :default)
32
-
33
- self.default_value = options.delete(:default)
24
+ default_option = options.delete(:default)
34
25
 
35
26
  save_options(options)
36
27
 
28
+ self.default_value = default_option
29
+
37
30
  @owner = owner
38
31
  @tag_type = tag_type
39
32
  end
@@ -48,7 +41,7 @@ module ActsAsTaggableOnMongoid
48
41
  tags_table
49
42
  taggings_table].each_with_object({}) { |dup_key, opts_hash| opts_hash[dup_key] = tag_definition.public_send(dup_key) }
50
43
 
51
- dup_hash[:default] = [tag_definition.default, parse: false]
44
+ dup_hash[:default] = tag_definition.default.dup
52
45
 
53
46
  ActsAsTaggableOnMongoid::Taggable::TagTypeDefinition.new klass,
54
47
  tag_definition.tag_type,
@@ -155,55 +148,41 @@ module ActsAsTaggableOnMongoid
155
148
  def add_tag_list
156
149
  add_list_getter
157
150
  add_list_setter
151
+ add_tag_list_from
152
+ add_tagger_tag_list
153
+ add_tagger_tag_lists
158
154
  add_all_list_getter
159
155
  add_list_exists
156
+
157
+ add_tag_list_change_methods
158
+ end
159
+
160
+ def add_tag_list_change_methods
160
161
  add_list_change
161
162
  add_list_changed
162
163
  add_changed_from_default?
163
164
  add_will_change
164
165
  add_get_was
166
+ add_get_lists_was
167
+ add_tagger_get_was
165
168
  add_reset_list
166
169
  add_reset_to_default
167
170
  end
168
171
 
169
- def add_list_getter
170
- tag_definition = self
171
- tag_list_name = tag_definition.tag_list_name
172
-
173
- owner.taggable_mixin.module_eval do
174
- define_method(tag_list_name) do
175
- tag_list_on tag_definition
176
- end
177
-
178
- alias_method "#{tag_list_name}_before_type_cast".to_sym, tag_list_name.to_sym
179
- end
180
- end
181
-
182
- def add_list_setter
183
- tag_definition = self
184
-
185
- owner.taggable_mixin.module_eval do
186
- define_method("#{tag_definition.tag_list_name}=") do |new_tags|
187
- dup_tags = Array.wrap(new_tags).dup
188
- options = dup_tags.extract_options!.dup
189
- options[:parse] = options.fetch(:parse) { true }
190
-
191
- new_list = tag_definition.parse(*dup_tags, options)
192
-
193
- mark_tag_list_changed(new_list)
194
- tag_list_set(new_list)
195
- end
196
- end
197
- end
198
-
199
- def add_all_list_getter
200
- tag_definition = self
172
+ def self.extract_tag_definition_options(options)
173
+ options = options.dup
201
174
 
202
- owner.taggable_mixin.module_eval do
203
- define_method(tag_definition.all_tag_list_name) do
204
- all_tags_list_on tag_definition
205
- end
206
- end
175
+ options.assert_valid_keys(:parser,
176
+ :preserve_tag_order,
177
+ :cached_in_model,
178
+ :force_lowercase,
179
+ :force_parameterize,
180
+ :remove_unused_tags,
181
+ :tags_table,
182
+ :taggings_table,
183
+ :default,
184
+ :tagger)
185
+ options
207
186
  end
208
187
 
209
188
  private
@@ -3,11 +3,7 @@
3
3
  module ActsAsTaggableOnMongoid
4
4
  module Taggable
5
5
  class TagTypeDefinition
6
- # This module extracts out the basic configuration type attributes of the tag definition.
7
- #
8
- # All attributes are based off of the Configuration class and in fact will default to
9
- # the corresponding value in the configuration if not explicitly specified/set when the
10
- # tag is defined.
6
+ # This module defines methods used to evaluate the attributes of the Tag Type Definition
11
7
  module Attributes
12
8
  attr_reader :cached_in_model,
13
9
  :default
@@ -62,14 +58,69 @@ module ActsAsTaggableOnMongoid
62
58
  alias force_parameterize? force_parameterize
63
59
  alias remove_unused_tags? remove_unused_tags
64
60
 
61
+ def tagger?
62
+ instance_variable_defined?(:@tagger)
63
+ end
64
+
65
+ def tag_list_uses_default_tagger?
66
+ return false if !tagger? || default_tagger_method.blank?
67
+
68
+ tagger_params.fetch(:tag_list_uses_default_tagger) { false }
69
+ end
70
+
71
+ def default_tagger_method
72
+ return nil unless tagger?
73
+
74
+ tagger_params[:default_tagger]
75
+ end
76
+
77
+ # :reek:FeatureEnvy
78
+ # :reek:DuplicateMethodCall
79
+ def taggable_default(taggable)
80
+ default_list = default
81
+
82
+ return unless default_list.present?
83
+
84
+ default_list = default_list.dup
85
+ default_list.taggable = taggable
86
+ default_list.tagger = default_list.tagger
87
+
88
+ default_list
89
+ end
90
+
91
+ def default_tagger(taggable)
92
+ return nil if default_tagger_method.nil?
93
+ return nil if taggable.blank?
94
+
95
+ taggable.public_send(default_tagger_method)
96
+ end
97
+
98
+ def tag_list_default_tagger(taggable)
99
+ return nil unless tag_list_uses_default_tagger?
100
+
101
+ default_tagger(taggable)
102
+ end
103
+
65
104
  private
66
105
 
106
+ def tagger_params
107
+ return @tagger_params if defined?(@tagger_params)
108
+
109
+ params = instance_variable_get(:@tagger)
110
+
111
+ @tagger_params = if tagger? && params.is_a?(Hash)
112
+ params.with_indifferent_access
113
+ else
114
+ HashWithIndifferentAccess.new
115
+ end
116
+ end
117
+
67
118
  def default_value=(value)
68
119
  dup_value = Array.wrap(value).dup
69
120
  options = dup_value.extract_options!.dup
70
121
  options[:parse] = options.fetch(:parse) { true }
71
122
 
72
- @default = ActsAsTaggableOnMongoid::TagList.new self, dup_value, options
123
+ @default = ActsAsTaggableOnMongoid::TagList.new self, *dup_value, options
73
124
  end
74
125
  end
75
126
  end