Class: Sabbath::Server::DeferrableBody
- Inherits:
-
Object
- Object
- Sabbath::Server::DeferrableBody
- Includes:
- EventMachine::Deferrable
- Defined in:
- lib/sabbath/server.rb
Instance Attribute Summary collapse
-
#jsonp_callback ⇒ Object
Returns the value of attribute jsonp_callback.
Instance Method Summary collapse
Instance Attribute Details
#jsonp_callback ⇒ Object
Returns the value of attribute jsonp_callback.
27 28 29 |
# File 'lib/sabbath/server.rb', line 27 def jsonp_callback @jsonp_callback end |
Instance Method Details
#call(body) ⇒ Object
29 30 31 32 33 |
# File 'lib/sabbath/server.rb', line 29 def call(body) body.each do |chunk| @body_callback.call(chunk) end end |
#each(&blk) ⇒ Object
35 36 37 |
# File 'lib/sabbath/server.rb', line 35 def each(&blk) @body_callback = blk end |
#succeed_with(body) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/sabbath/server.rb', line 39 def succeed_with(body) data = if jsonp_callback "#{jsonp_callback}(#{body.to_json})" else body.to_json end puts "sending #{data.inspect}" call(Array(data)) succeed end |