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: Encoders, Transports Classes: Config, Event

Constant Summary collapse

VERSION =
'0.5.1'

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object



65
66
67
68
69
70
71
# File 'lib/waffle.rb', line 65

def method_missing meth, *args
  if Config.configured?
    config.queues[:default].send(meth, *args)
  else
    super
  end
end

Instance Method Details

#configObject



47
48
49
# File 'lib/waffle.rb', line 47

def config
  Config if Config.configured?
end

#configure(options = nil, &block) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/waffle.rb', line 38

def configure options = nil, &block
  if block_given?
    Config.class_eval(&block)
  else
    options = {:path => 'config/waffle.yml'} unless options
    Config.load!(options)
  end
end

#publish(flow = 'events', message = '') ⇒ Object



55
56
57
58
# File 'lib/waffle.rb', line 55

def publish flow = 'events', message = ''
  raise "Waffle is not configured" unless Config.configured?
  config.queues[:default].publish(flow, message)
end

#queue(name = :default) ⇒ Object



51
52
53
# File 'lib/waffle.rb', line 51

def queue name = :default
  config.queues[name] or raise "Transport '#{name}' is not configured"
end

#reset_config!Object



34
35
36
# File 'lib/waffle.rb', line 34

def reset_config!
  config.reset_config! if config
end

#subscribe(flow = '', &block) ⇒ Object



60
61
62
63
# File 'lib/waffle.rb', line 60

def subscribe flow = '', &block
  raise "Waffle is not configured" unless Config.configured?
  config.queues[:default].subscribe(flow, &block)
end