Sha256: 924e0258c0ff847e645030f5308360689c76087e95960576835e033a4ad97ff2
Contents?: true
Size: 1009 Bytes
Versions: 1
Compression:
Stored size: 1009 Bytes
Contents
require 'yaml' require 'active_support/core_ext/hash/keys' module AMQP module Integration class Rails # @return [String] application environment def self.environment if defined?(::Rails) ::Rails.env else ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development' end end # @return [String] application root directory def self.root defined?(::Rails) && ::Rails.root || Dir.pwd end def self.start(options_or_uri = {}, &block) yaml = YAML.load_file(File.join(root, 'config', 'amqp.yml')) settings = yaml.fetch(environment, Hash.new).symbolize_keys arg = if options_or_uri.is_a?(Hash) settings.merge(options_or_uri)[:uri] else settings[:uri] || options_or_uri end EventMachine.next_tick do AMQP.start(arg, &block) end end end # Rails end # Integration end # AMQP
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
synapses-0.0.1 | lib/amqp/integration/rails.rb |