# File lib/acts_as_taggable_on/acts_as_taggable_on/ownership.rb, line 46 def cached_owned_tag_list_on(context) variable_name = "@owned_#{context}_list" cache = instance_variable_get(variable_name) || instance_variable_set(variable_name, {}) end
# File lib/acts_as_taggable_on/acts_as_taggable_on/ownership.rb, line 51 def owner_tag_list_on(owner, context) add_custom_context(context) cache = cached_owned_tag_list_on(context) cache.delete_if { |key, value| key.id == owner.id && key.class == owner.class } cache[owner] ||= ActsAsTaggableOn::TagList.new(*owner_tags_on(owner, context).map(&:name)) end
# File lib/acts_as_taggable_on/acts_as_taggable_on/ownership.rb, line 69 def reload(*args) self.class.tag_types.each do |context| instance_variable_set("@owned_#{context}_list", nil) end super(*args) end
# File lib/acts_as_taggable_on/acts_as_taggable_on/ownership.rb, line 60 def set_owner_tag_list_on(owner, context, new_list) add_custom_context(context) cache = cached_owned_tag_list_on(context) cache.delete_if { |key, value| key.id == owner.id && key.class == owner.class } cache[owner] = ActsAsTaggableOn::TagList.from(new_list) end