parolkar/pfeed

Send feed to participant

Opened this issue · 0 comments

Consider a where User A completed some task for User B. In this case I want to create pfeed for both user A and User B. I sent orignator to User A and participant to User B and have a participant method to return User B as one of the person to which the pfeedItem should be delivered. However, deliver method in pfeed only calls the orignator object without passing itself and there is no way for the orignator object to return the participant. I have changed deliver method as follows to send the pfeedItem itself

def deliver(ar_obj,method_name_arr)
method_name_arr.map { |method_name|
if ar_obj.method(method_name).arity > 0
ar_obj.send(method_name, self)
else
ar_obj.send(method_name)
end
}.flatten.uniq.map {|o| deliver_to(o) }.compact
end

Let me know if there is a better to do that.