Module: Riddl::Utils::Notifications::Producer

Defined in:
lib/ruby/riddl/utils/notifications_producer.rb

Defined Under Namespace

Classes: Backend, CreateSubscription, DeleteSubscription, HandlerBase, Overview, Subscription, Subscriptions, Topics, UpdateSubscription, WS

Class Method Summary collapse

Class Method Details

.implementation(backend, handler = nil, details = :production) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# 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