# File lib/acts_as_taggable_on/acts_as_taggable_on/core.rb, line 208 def add_custom_context(value) custom_contexts << value.to_s unless custom_contexts.include?(value.to_s) or self.class.tag_types.map(&:to_s).include?(value.to_s) end
# File lib/acts_as_taggable_on/acts_as_taggable_on/core.rb, line 212 def cached_tag_list_on(context) self["cached_#{context.to_s.singularize}_list"] end
# File lib/acts_as_taggable_on/acts_as_taggable_on/core.rb, line 200 def custom_contexts @custom_contexts ||= [] end
all column names are necessary for PostgreSQL group clause
# File lib/acts_as_taggable_on/acts_as_taggable_on/core.rb, line 196 def grouped_column_names_for(object) self.class.grouped_column_names_for(object) end
# File lib/acts_as_taggable_on/acts_as_taggable_on/core.rb, line 204 def is_taggable? self.class.is_taggable? end
# File lib/acts_as_taggable_on/acts_as_taggable_on/core.rb, line 280 def process_dirty_object(context,new_list) value = new_list.is_a?(Array) ? new_list.join(', ') : new_list attrib = "#{context.to_s.singularize}_list" if changed_attributes.include?(attrib) # The attribute already has an unsaved change. old = changed_attributes[attrib] changed_attributes.delete(attrib) if (old.to_s == value.to_s) else old = tag_list_on(context).to_s changed_attributes[attrib] = old if (old.to_s != value.to_s) end end
# File lib/acts_as_taggable_on/acts_as_taggable_on/core.rb, line 294 def reload(*args) self.class.tag_types.each do |context| instance_variable_set("@#{context.to_s.singularize}_list", nil) instance_variable_set("@all_#{context.to_s.singularize}_list", nil) end super(*args) end
# File lib/acts_as_taggable_on/acts_as_taggable_on/core.rb, line 267 def set_tag_list_on(context, new_list) add_custom_context(context) variable_name = "@#{context.to_s.singularize}_list" process_dirty_object(context, new_list) unless custom_contexts.include?(context.to_s) instance_variable_set(variable_name, ActsAsTaggableOn::TagList.from(new_list)) end
# File lib/acts_as_taggable_on/acts_as_taggable_on/core.rb, line 221 def tag_list_cache_on(context) variable_name = "@#{context.to_s.singularize}_list" instance_variable_get(variable_name) || instance_variable_set(variable_name, ActsAsTaggableOn::TagList.new(tags_on(context).map(&:name))) end
# File lib/acts_as_taggable_on/acts_as_taggable_on/core.rb, line 216 def tag_list_cache_set_on(context) variable_name = "@#{context.to_s.singularize}_list" !instance_variable_get(variable_name).nil? end
# File lib/acts_as_taggable_on/acts_as_taggable_on/core.rb, line 226 def tag_list_on(context) add_custom_context(context) tag_list_cache_on(context) end
# File lib/acts_as_taggable_on/acts_as_taggable_on/core.rb, line 276 def tagging_contexts custom_contexts + self.class.tag_types.map(&:to_s) end