Class: Profit::MessageHandler
- Inherits:
-
Object
- Object
- Profit::MessageHandler
- Includes:
- EM::Deferrable
- Defined in:
- lib/profit/message_handler.rb
Instance Attribute Summary collapse
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(json, conn) ⇒ MessageHandler
constructor
A new instance of MessageHandler.
- #run ⇒ Object
Constructor Details
#initialize(json, conn) ⇒ MessageHandler
Returns a new instance of MessageHandler.
10 11 12 |
# File 'lib/profit/message_handler.rb', line 10 def initialize(json, conn) @json, @conn = json, conn end |
Instance Attribute Details
#text ⇒ Object (readonly)
Returns the value of attribute text.
8 9 10 |
# File 'lib/profit/message_handler.rb', line 8 def text @text end |
Instance Method Details
#run ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/profit/message_handler.rb', line 14 def run return succeed("Starting") if @json.empty? = JSON.parse(@json) key = .delete("metric_type") response = @conn.rpush key, .to_json if response == "OK" succeed response else fail response end end |