module ActsAsMentionable::Mentioner
Public Instance Methods
mention(*mentionables, save: false)
click to toggle source
# File lib/acts_as_mentionable/mentioner.rb, line 20 def mention *mentionables, save: false mentionables_manipulator.add(*mentionables) return_changes { save_mentions if save } end
mentionables()
click to toggle source
# File lib/acts_as_mentionable/mentioner.rb, line 16 def mentionables RetrievePolymorphic.new(mentions, :mentionable).call end
mentioner?()
click to toggle source
# File lib/acts_as_mentionable/mentioner.rb, line 12 def mentioner? true end
replace_mentionables(*mentionables, save: false)
click to toggle source
# File lib/acts_as_mentionable/mentioner.rb, line 30 def replace_mentionables *mentionables, save: false mentionables_manipulator.replace(*mentionables) return_changes { save_mentions if save } end
save_mentions()
click to toggle source
# File lib/acts_as_mentionable/mentioner.rb, line 35 def save_mentions return unless mentionables_manipulator.changed? return_changes do MentionsUpdater.new(self, mentionables_manipulator.changes).call do fix_mentionables_changes! end end end
unmention(*mentionables, save: false)
click to toggle source
# File lib/acts_as_mentionable/mentioner.rb, line 25 def unmention *mentionables, save: false mentionables_manipulator.remove(*mentionables) return_changes { save_mentions if save } end
Private Instance Methods
fix_mentionables_changes!()
click to toggle source
# File lib/acts_as_mentionable/mentioner.rb, line 59 def fix_mentionables_changes! mentionables_manipulator.fix_changes! TransactionCallbacks.on_rolled_back do current = mentionables_manipulator.current refresh_mentionables_manipulator! mentionables_manipulator.replace current end end
mentionables_manipulator()
click to toggle source
# File lib/acts_as_mentionable/mentioner.rb, line 51 def mentionables_manipulator @mentionables_manipulator ||= MentionablesManipulator.new mentionables end
refresh_mentionables_manipulator!()
click to toggle source
# File lib/acts_as_mentionable/mentioner.rb, line 55 def refresh_mentionables_manipulator! remove_instance_variable :@mentionables_manipulator end
return_changes() { || ... }
click to toggle source
# File lib/acts_as_mentionable/mentioner.rb, line 47 def return_changes mentionables_manipulator.changes.tap { yield } end