Module: ActsAsTaggableOnMongoid::Taggable::Changeable
- Defined in:
- lib/acts_as_taggable_on_mongoid/taggable/changeable.rb
Overview
Overides of methods from Mongoid::Changeable
Instance Method Summary collapse
- #changed ⇒ Object
- #changes ⇒ Object
- #reload(*args) ⇒ Object
- #setters ⇒ Object
- #tag_list_on_changed(tag_definition) ⇒ Object
Instance Method Details
#changed ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# 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 ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# 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 changed_attributes.key? tag_list_name changed_values[tag_list_name] = [changed_attributes[tag_list_name], public_send(tag_list_name)] end changed_values end |
#reload(*args) ⇒ Object
11 12 13 14 15 16 17 18 |
# 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 ⇒ Object
51 52 53 54 55 56 57 58 |
# 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) ⇒ Object
7 8 9 |
# 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 |