API seems a little uncomfortable for now, anyway here's sample code that works in current merit master (1515c6463f92aaace6298015c0f8e70064885779):
class ReputationChangeObserver
def update(changed_data)
# description will be something like:
# granted 5 points
# granted just-registered badge
# removed autobiographer badge
description = changed_data[:description]
# If user is your meritable model, you can grab it like:
if changed_data[:merit_object]
sash_id = changed_data[:merit_object].sash_id
user = User.where(sash_id: sash_id).first
end
# To know where and when it happened:
merit_action = Merit::Action.find changed_data[:merit_action_id]
controller = merit_action.target_model
action = merit_action.action_method
when = merit_action.created_at
# From here on, you can create a new Notification assuming that's an
# ActiveRecord Model in your app, send an email, etc. For example:
Notification.create(
user: user,
what: description,
where: "#{controller}##{action}",
when: when)
end
end
EDIT: Please note that API has changed since this answer, see https://github.com/tute/merit#getting-notifications.