Module: Intervention

Defined in:
lib/intervention.rb,
lib/intervention/client.rb,
lib/intervention/server.rb,
lib/intervention/version.rb

Defined Under Namespace

Classes: Client, Server

Constant Summary collapse

VERSION =
"0.1.1".freeze
DATE =
"2013-11-11".freeze

Class Method Summary collapse

Class Method Details

.callback(object) ⇒ Object



41
42
43
44
# File 'lib/intervention.rb', line 41

def callback object
  @config.callbacks ||= []
  @config.callbacks << object
end

.callbacksObject



54
55
56
# File 'lib/intervention.rb', line 54

def callbacks
  @config.callbacks ||= []
end

.clientsObject



58
59
60
# File 'lib/intervention.rb', line 58

def clients
  @config.clients ||= []
end

.configObject



46
47
48
# File 'lib/intervention.rb', line 46

def config
  @config ||= Hashie::Mash.new
end

.configure {|config| ... } ⇒ Object

Yields:



32
33
34
# File 'lib/intervention.rb', line 32

def configure
  yield config
end

.event_handlersObject



50
51
52
# File 'lib/intervention.rb', line 50

def event_handlers
  @config.event_handlers ||= Hashie::Mash.new
end

.method_missing(meth, *args, **kwargs, &block) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/intervention.rb', line 20

def method_missing meth, *args, **kwargs, &block
  if config.respond_to? meth
    config.send meth, *args, **kwargs, &block
  else
    super
  end
end

.on(event, &block) ⇒ Object



36
37
38
39
# File 'lib/intervention.rb', line 36

def on event, &block
  @config.event_handlers ||= Hashie::Mash.new
  @config.event_handlers[event] = block
end

.serversObject



62
63
64
# File 'lib/intervention.rb', line 62

def servers
  @config.servers ||= []
end

.start(*args, **kwargs, &block) ⇒ Object



28
29
30
# File 'lib/intervention.rb', line 28

def start *args, **kwargs, &block
  EventMachine.start_server 'localhost', config.listen_port, Intervention::Client
end