Class: Alephant::Broker::Application
- Inherits:
-
Object
- Object
- Alephant::Broker::Application
- Defined in:
- lib/alephant/broker/application.rb
Instance Attribute Summary collapse
-
#load_strategy ⇒ Object
readonly
Returns the value of attribute load_strategy.
Instance Method Summary collapse
- #call(env) ⇒ Object
- #environment_for(env) ⇒ Object
-
#initialize(load_strategy, c = nil) ⇒ Application
constructor
A new instance of Application.
- #response_for(call_environment) ⇒ Object
- #send(response) ⇒ Object
Constructor Details
#initialize(load_strategy, c = nil) ⇒ Application
Returns a new instance of Application.
6 7 8 9 |
# File 'lib/alephant/broker/application.rb', line 6 def initialize(load_strategy, c = nil) Broker.config = c unless c.nil? @load_strategy = load_strategy end |
Instance Attribute Details
#load_strategy ⇒ Object (readonly)
Returns the value of attribute load_strategy.
4 5 6 |
# File 'lib/alephant/broker/application.rb', line 4 def load_strategy @load_strategy end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 |
# File 'lib/alephant/broker/application.rb', line 11 def call(env) send response_for(environment_for(env)) end |
#environment_for(env) ⇒ Object
15 16 17 |
# File 'lib/alephant/broker/application.rb', line 15 def environment_for(env) Environment.new env end |
#response_for(call_environment) ⇒ Object
19 20 21 |
# File 'lib/alephant/broker/application.rb', line 19 def response_for(call_environment) Broker.handle(load_strategy, call_environment) end |
#send(response) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/alephant/broker/application.rb', line 23 def send(response) [ response.status, response.headers, [ response.content.to_s ] ] end |