Module: Redmineup::ActsAsTaggable::Taggable::InstanceMethods
- Defined in:
- lib/redmineup/acts_as_taggable/up_acts_as_taggable.rb
Instance Method Summary collapse
-
#all_tags_list ⇒ Object
build list from related tags.
-
#reload_with_tag_list(*args) ⇒ Object
:nodoc:.
- #save_cached_tag_list ⇒ Object
- #save_tags ⇒ Object
-
#tag_counts(options = {}) ⇒ Object
Calculate the tag counts for the tags used by this model.
- #tag_list ⇒ Object
- #tag_list=(value) ⇒ Object
Instance Method Details
#all_tags_list ⇒ Object
build list from related tags
347 348 349 |
# File 'lib/redmineup/acts_as_taggable/up_acts_as_taggable.rb', line 347 def .pluck(:name) end |
#reload_with_tag_list(*args) ⇒ Object
:nodoc:
380 381 382 383 |
# File 'lib/redmineup/acts_as_taggable/up_acts_as_taggable.rb', line 380 def reload_with_tag_list(*args) #:nodoc: @tag_list = nil reload_without_tag_list(*args) end |
#save_cached_tag_list ⇒ Object
340 341 342 343 344 |
# File 'lib/redmineup/acts_as_taggable/up_acts_as_taggable.rb', line 340 def save_cached_tag_list if self.class.caching_tag_list? self[self.class.cached_tag_list_column_name] = tag_list.to_s end end |
#save_tags ⇒ Object
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
# File 'lib/redmineup/acts_as_taggable/up_acts_as_taggable.rb', line 351 def return unless @tag_list new_tag_names = @tag_list - .map(&:name) = .reject { |tag| @tag_list.include?(tag.name) } self.class.transaction do if .any? taggings.where("tag_id IN (?)", .map(&:id)).each(&:destroy) taggings.reset end new_tag_names.each do |new_tag_name| << Tag.find_or_create_with_like_by_name(new_tag_name) end end true end |
#tag_counts(options = {}) ⇒ Object
Calculate the tag counts for the tags used by this model.
The possible options are the same as the tag_counts class method.
373 374 375 376 377 378 |
# File 'lib/redmineup/acts_as_taggable/up_acts_as_taggable.rb', line 373 def tag_counts( = {}) return [] if tag_list.blank? [:conditions] = self.class.send(:merge_conditions, [:conditions], self.class.send(:tags_condition, tag_list)) self.class.tag_counts() end |
#tag_list ⇒ Object
326 327 328 329 330 331 332 333 334 |
# File 'lib/redmineup/acts_as_taggable/up_acts_as_taggable.rb', line 326 def tag_list return @tag_list if @tag_list ||= nil if self.class.caching_tag_list? && !(cached_value = send(self.class.cached_tag_list_column_name)).nil? @tag_list = TagList.from(cached_value) else @tag_list = TagList.new(*.map(&:name)) end end |
#tag_list=(value) ⇒ Object
336 337 338 |
# File 'lib/redmineup/acts_as_taggable/up_acts_as_taggable.rb', line 336 def tag_list=(value) @tag_list = TagList.from(value) end |