module Riddl::Utils::Notifications::Producer

Public Class Methods

implementation(backend,handler=nil,details=:production) click to toggle source
# File lib/ruby/riddl/utils/notifications_producer.rb, line 7
def self::implementation(backend,handler=nil,details=:production)
  unless handler.nil? || (handler.is_a? Riddl::Utils::Notifications::Producer::HandlerBase)
    raise "handler not a subclass of HandlerBase"
  end
  Proc.new do
    on resource "notifications" do
      run Riddl::Utils::Notifications::Producer::Overview if get
      on resource "topics" do
        run Riddl::Utils::Notifications::Producer::Topics, backend if get
      end
      on resource "subscriptions" do
        run Riddl::Utils::Notifications::Producer::Subscriptions, backend, details if get
        run Riddl::Utils::Notifications::Producer::CreateSubscription, backend, handler if post 'subscribe'
        on resource do
          run Riddl::Utils::Notifications::Producer::Subscription, backend, details if get 'request'
          run Riddl::Utils::Notifications::Producer::UpdateSubscription, backend, handler if put 'details'
          run Riddl::Utils::Notifications::Producer::DeleteSubscription, backend, handler if delete 'delete'
          on resource 'ws' do
            run Riddl::Utils::Notifications::Producer::WS, backend, handler if websocket
          end
        end
      end
    end
  end
end