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.6.0'

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object



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

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

Instance Method Details

#configObject



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

def config
  Config if Config.configured?
end

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



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

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



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

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

#queue(name = :default) ⇒ Object



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

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

#reset_config!Object



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

def reset_config!
  config.reset_config! if config
end

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



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

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