Class: Pixo::Rpc::AddPattern

Inherits:
Object
  • Object
show all
Defined in:
lib/pixo/rpc/request_types.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, code) ⇒ AddPattern

Returns a new instance of AddPattern.



18
19
20
21
# File 'lib/pixo/rpc/request_types.rb', line 18

def initialize(name, code)
  @name = name
  @code = code
end

Instance Method Details

#call(service) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/pixo/rpc/request_types.rb', line 23

def call(service)
  result = nil
  latch = Concurrent::CountDownLatch.new(1)

  service.application.post( Proc.new do |app|
          app.add_pattern(@name, @code)
          result = @name
          latch.count_down
        end)
  latch.wait

  result
end