Class: RedSocket::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/red_socket.rb

Class Method Summary collapse

Class Method Details

.account_idObject



16
17
18
# File 'lib/red_socket.rb', line 16

def self.
  @@account_id
end

.account_id=(value) ⇒ Object



20
21
22
# File 'lib/red_socket.rb', line 20

def self.(value)
  @@account_id = value
end

.api_keyObject



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_secretObject



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

Yields:

  • (_self)

Yield Parameters:



40
41
42
43
# File 'lib/red_socket.rb', line 40

def self.configure
  yield self
  self
end

.hostObject



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", message="")
  ::EventMachine.run {
    http = ::EventMachine::HttpRequest.
        new("http://#{}.#{host}/api/messages.json").
        post :body =>
                 {
                     'api_key' => api_key,
                     'channel' => channel,
                     'event' => event,
                     'message' => 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