houdini/lib/insert/insert_supporter_notes.rb

23 lines
730 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2020-06-12 20:03:43 +00:00
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
module InsertSupporterNotes
#note_supporter_users : array of hashes
# each hash:
# supporter: Supporter new note should belong to
# user: User creating the note
# note: parameters to pass into the note
def self.create(*note_supporter_users)
inserted = nil
ActiveRecord::Base.transaction do
inserted = note_supporter_users.map do |nsu|
nsu[:supporter].supporter_notes.create!(content: nsu[:content], user: nsu[:user])
end
InsertActivities.for_supporter_notes(inserted)
end
inserted
end
end