Module: ActsAsTaggableOn::Taggable::Core::InstanceMethods

Defined in:
lib/acts_as_taggable_on/social_stream.rb

Instance Method Summary collapse

Instance Method Details

#process_dirty_object(context, new_list) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/acts_as_taggable_on/social_stream.rb', line 43

def process_dirty_object(context,new_list)
  value = new_list.is_a?(Array) ? new_list.join(', ') : new_list
  attr = "#{context.to_s.singularize}_list"

  if changed_attributes.include?(attr)
    # The attribute already has an unsaved change.
    old = changed_attributes[attr]
    changed_attributes.delete(attr) if (old.to_s == value.to_s)
  else
    old = tag_list_on(context).to_s
    changed_attributes[attr] = old if (old.to_s != value.to_s)
  end
end

#set_tag_list_on(context, new_list) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/acts_as_taggable_on/social_stream.rb', line 34

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)        

  instance_variable_set(variable_name, ActsAsTaggableOn::TagList.from(new_list))
end