Sha256: 125e250697a7951e99906a355eeb6fce63f90eb4c7f2697ef1d60c67352b6680
Contents?: true
Size: 708 Bytes
Versions: 53
Compression:
Stored size: 708 Bytes
Contents
# frozen_string_literal: true module Motor module Notes module Persist TAG_REGEXP = /#\w+?\b/.freeze module_function def call(note, current_user) note.author ||= current_user tags = parse_tag_names(note) Motor::Notes::Tags.assign_tags(note, tags) note.save! broadcast_note(note) note end def broadcast_note(note) Motor::NotesChannel.broadcast_to( note.values_at(:record_type, :record_id).join(':'), ['update', note.as_json(include: %i[author tags reminders])] ) end def parse_tag_names(note) note.body.scan(TAG_REGEXP).pluck(1..) end end end end
Version data entries
53 entries across 53 versions & 6 rubygems