++ed by:
KEEDI ADAMJS MHOWARD

3 PAUSE users

Nils Diewald

NAME

Mojolicious::Plugin::Notifications::JSON - Event Notifications in JSON

SYNOPSIS

  # Register the engine
  plugin Notifications => {
    JSON => 1
  };

  # In the controller
  $c->render(json => $c->notifications(json => $json));

DESCRIPTION

This plugin is a simple notification engine for JSON.

If it does not suit your needs, you can easily write your own engine.

METHODS

Mojolicious::Plugin::Notifications::JSON inherits all methods from Mojolicious::Plugin::Notifications::Engine and implements the following new one.

register

  plugin Notifications => {
    JSON => {
      key => 'notes'
    }
  };

Called when registering the main plugin. All parameters under the key JSON are passed to the registration.

Accepts the following parameters:

key

Define the attribute name of the notification array. Defaults to notifications.

HELPERS

notify

See the base notify helper.

notifications

  $c->render(json => $c->notifications(json => $json));
  $c->render(json => $c->notifications(json => $json, key => 'notes'));

Merge notifications into your JSON response.

In case JSON is an object, it will inject an attribute that points to an array reference containing the notifications. If the JSON is an array, an object is appended with one attribute that points to an array reference containing the notifications. If the JSON is empty, an object will be created with one attribute that points to an array reference containing the notifications.

If the JSON is not of one of the descripted types, it's returned unaltered.

The name of the attribute can either be given on registration or by passing a parameter for key. The name defaults to notifications.

AVAILABILITY

  https://github.com/Akron/Mojolicious-Plugin-Notifications

COPYRIGHT AND LICENSE

Copyright (C) 2014-2015, Nils Diewald.

This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.