socialforge/lib/trustie/at/at.rb

23 lines
588 B
Ruby
Raw Normal View History

2016-03-11 18:50:37 +08:00
#coding=utf-8
module Trustie
module At
extend ActiveSupport::Concern
module ClassMethods
def act_as_at_message(content, send_id)
self.send :define_method, :act_as_at_message_func do
users = self[content].scan /<span class="at" data-user-id="(.+?)">/m
users && users.flatten.uniq.each do |uids|
uids.split(",").each do |uid|
self.at_messages << AtMessage.new(user_id: uid, sender_id: self[send_id])
end
end
end
end
end
end
end
ActiveRecord::Base.send(:include, Trustie::At)