Class: Pubsubstub::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/pubsubstub/application.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApplication

Returns a new instance of Application.



3
4
5
6
# File 'lib/pubsubstub/application.rb', line 3

def initialize(*)
  @publish = PublishAction.new
  @stream = StreamAction.new
end

Class Method Details

.call(env) ⇒ Object



8
9
10
11
# File 'lib/pubsubstub/application.rb', line 8

def self.call(env)
  @instance ||= new
  @instance.call(env)
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/pubsubstub/application.rb', line 13

def call(env)
  request = Rack::Request.new(env)
  if request.get?
    @stream.call(env)
  else
    @publish.call(env)
  end
end