Class: Yup::State::FeedbackHandler
- Inherits:
-
EM::Connection
- Object
- EM::Connection
- Yup::State::FeedbackHandler
- Defined in:
- lib/yup/request_forwarder.rb
Instance Method Summary collapse
-
#initialize(state) ⇒ FeedbackHandler
constructor
A new instance of FeedbackHandler.
- #on_message(req) ⇒ Object
- #receive_data(data) ⇒ Object
Constructor Details
#initialize(state) ⇒ FeedbackHandler
Returns a new instance of FeedbackHandler.
163 164 165 166 167 168 169 170 171 |
# File 'lib/yup/request_forwarder.rb', line 163 def initialize(state) @state = state @yajl = Yajl::Parser.new(:symbolize_keys => true) @yajl.on_parse_complete = method(:on_message) @logger = Yup.logger.clone @logger.progname = "Yup::State::FeedbackHandler" end |
Instance Method Details
#on_message(req) ⇒ Object
181 182 183 |
# File 'lib/yup/request_forwarder.rb', line 181 def (req) @state.push(Yajl::Encoder.encode(req)) end |
#receive_data(data) ⇒ Object
173 174 175 176 177 178 179 |
# File 'lib/yup/request_forwarder.rb', line 173 def receive_data(data) begin @yajl << data rescue Yajl::ParseError @logger.error { "Error while parsing \"#{data}\"" } end end |