Module: Intervention
- Defined in:
- lib/intervention.rb,
lib/intervention/client.rb,
lib/intervention/server.rb,
lib/intervention/version.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
"0.1.1".freeze
- DATE =
"2013-11-11".freeze
Class Method Summary collapse
- .callback(object) ⇒ Object
- .callbacks ⇒ Object
- .clients ⇒ Object
- .config ⇒ Object
- .configure {|config| ... } ⇒ Object
- .event_handlers ⇒ Object
- .method_missing(meth, *args, **kwargs, &block) ⇒ Object
- .on(event, &block) ⇒ Object
- .servers ⇒ Object
- .start(*args, **kwargs, &block) ⇒ Object
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 |
.callbacks ⇒ Object
54 55 56 |
# File 'lib/intervention.rb', line 54 def callbacks @config.callbacks ||= [] end |
.clients ⇒ Object
58 59 60 |
# File 'lib/intervention.rb', line 58 def clients @config.clients ||= [] end |
.config ⇒ Object
46 47 48 |
# File 'lib/intervention.rb', line 46 def config @config ||= Hashie::Mash.new end |
.configure {|config| ... } ⇒ Object
32 33 34 |
# File 'lib/intervention.rb', line 32 def configure yield config end |
.event_handlers ⇒ Object
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 |
.servers ⇒ Object
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 |