Module: Waffle
- Extended by:
- Waffle
- Included in:
- Waffle
- Defined in:
- lib/waffle.rb,
lib/waffle/event.rb,
lib/waffle/config.rb,
lib/waffle/version.rb,
lib/waffle/encoders/json.rb,
lib/waffle/transports/base.rb,
lib/waffle/encoders/marshal.rb,
lib/waffle/transports/redis.rb,
lib/waffle/transports/rabbitmq.rb
Defined Under Namespace
Modules: Config, Encoders, Transports
Classes: Event
Constant Summary
collapse
- VERSION =
'0.4.0'
Instance Method Summary
collapse
Instance Method Details
29
30
31
32
33
34
35
36
|
# File 'lib/waffle.rb', line 29
def configure options=nil
@configured ||= begin
options = {:path => 'config/waffle.yml'} unless options
Config.load!(options)
true
end
block_given? ? yield(Config) : Config
end
|
#encoder ⇒ Object
57
58
59
|
# File 'lib/waffle.rb', line 57
def encoder
@encoder ||= "Waffle::Encoders::#{Waffle.config.encoder.camelize}".constantize
end
|
#publish(flow = 'events', message = '') ⇒ Object
38
39
40
41
42
|
# File 'lib/waffle.rb', line 38
def publish flow = 'events', message = ''
transport.publish(flow, message)
rescue *transport.connection_exceptions => e
transport.reconnect && retry if transport.ready_to_connect?
end
|
#reset_config! ⇒ Object
25
26
27
|
# File 'lib/waffle.rb', line 25
def reset_config!
@configured = false
end
|
#subscribe(flow = '', &block) ⇒ Object
44
45
46
47
48
49
50
51
|
# File 'lib/waffle.rb', line 44
def subscribe flow = '', &block
transport.subscribe(flow, &block)
rescue *transport.connection_exceptions => e
until transport.reconnect do
sleep(config.connection_attempt_timeout)
end
retry
end
|
#transport ⇒ Object
53
54
55
|
# File 'lib/waffle.rb', line 53
def transport
@transport ||= "Waffle::Transports::#{Waffle.config.transport.camelize}".constantize.new
end
|