Class: RedSocket::Base
- Inherits:
-
Object
- Object
- RedSocket::Base
- Defined in:
- lib/red_socket.rb
Class Method Summary collapse
- .account_id ⇒ Object
- .account_id=(value) ⇒ Object
- .api_key ⇒ Object
- .api_key=(value) ⇒ Object
- .api_secret ⇒ Object
- .api_secret=(value) ⇒ Object
- .configure {|_self| ... } ⇒ Object
- .host ⇒ Object
- .host=(value) ⇒ Object
- .notify(channel, event = "notification", message = "") ⇒ Object
Class Method Details
.account_id ⇒ Object
16 17 18 |
# File 'lib/red_socket.rb', line 16 def self.account_id @@account_id end |
.account_id=(value) ⇒ Object
20 21 22 |
# File 'lib/red_socket.rb', line 20 def self.account_id=(value) @@account_id = value end |
.api_key ⇒ Object
8 9 10 |
# File 'lib/red_socket.rb', line 8 def self.api_key @@api_key end |
.api_key=(value) ⇒ Object
12 13 14 |
# File 'lib/red_socket.rb', line 12 def self.api_key=(value) @@api_key = value end |
.api_secret ⇒ Object
24 25 26 |
# File 'lib/red_socket.rb', line 24 def self.api_secret @@api_secret end |
.api_secret=(value) ⇒ Object
28 29 30 |
# File 'lib/red_socket.rb', line 28 def self.api_secret=(value) @@api_secret = value end |
.configure {|_self| ... } ⇒ Object
40 41 42 43 |
# File 'lib/red_socket.rb', line 40 def self.configure yield self self end |
.host ⇒ Object
32 33 34 |
# File 'lib/red_socket.rb', line 32 def self.host @@host ||= "red-socket.com" end |
.host=(value) ⇒ Object
36 37 38 |
# File 'lib/red_socket.rb', line 36 def self.host=(value) @@host = value end |
.notify(channel, event = "notification", message = "") ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/red_socket.rb', line 45 def self.notify(channel, event="notification", ="") ::EventMachine.run { http = ::EventMachine::HttpRequest. new("http://#{account_id}.#{host}/api/messages.json"). post :body => { 'api_key' => api_key, 'channel' => channel, 'event' => event, 'message' => } http.errback { p 'Uh oh'; EM.stop } http.callback { p http.response_header.status p http.response_header p http.response EventMachine.stop } } end |