module ActsAsTaggableOnMongoid::Taggable::Changeable
Overides of methods from Mongoid::Changeable
Public Instance Methods
changed()
click to toggle source
Calls superclass method
# File lib/acts_as_taggable_on_mongoid/taggable/changeable.rb, line 20 def changed changed_values = super tag_list_names = tag_types.values.map(&:tag_list_name).map(&:to_s) changed_attributes.each_key do |key| next unless tag_list_names.include?(key.to_s) if public_send("#{key}_changed?") changed_values << key unless changed_values.include?(key) else changed_values.delete(key) end end changed_values end
changes()
click to toggle source
Calls superclass method
# File lib/acts_as_taggable_on_mongoid/taggable/changeable.rb, line 37 def changes changed_values = super tag_types.each_value do |tag_definition| tag_list_name = tag_definition.tag_list_name next unless public_send("#{tag_list_name}_changed?") changed_values[tag_list_name] = public_send("#{tag_list_name}_change") end changed_values end
reload(*args)
click to toggle source
Calls superclass method
# File lib/acts_as_taggable_on_mongoid/taggable/changeable.rb, line 11 def reload(*args) tag_types.each_value do |tag_definition| instance_variable_set tag_definition.all_tag_list_variable_name, nil instance_variable_set tag_definition.tag_list_variable_name, nil end super(*args) end
setters()
click to toggle source
Calls superclass method
# File lib/acts_as_taggable_on_mongoid/taggable/changeable.rb, line 51 def setters setter_values = super tag_list_names = tag_types.values.map(&:tag_list_name).map(&:to_s) setter_values.delete_if do |key, _value| tag_list_names.include?(key.to_s) end end
tag_list_on_changed(tag_definition)
click to toggle source
# File lib/acts_as_taggable_on_mongoid/taggable/changeable.rb, line 7 def tag_list_on_changed(tag_definition) attribute_will_change!(tag_definition.tag_list_name) end
Private Instance Methods
attribute_will_change!(attribute_name)
click to toggle source
Calls superclass method
# File lib/acts_as_taggable_on_mongoid/taggable/changeable.rb, line 62 def attribute_will_change!(attribute_name) tag_definition = tag_types.detect { |_tag_name, tag_def| tag_def.tag_list_name.to_s == attribute_name.to_s }&.last return super if tag_definition.blank? return if changed_attributes.key?(attribute_name) changed_attributes[attribute_name] = tag_list_cache_on(tag_definition)&.dup end