Class: ActivePublisher::Configuration
- Inherits:
-
Object
- Object
- ActivePublisher::Configuration
- Defined in:
- lib/active_publisher/configuration.rb
Constant Summary collapse
- CONFIGURATION_MUTEX =
::Mutex.new
- DEFAULTS =
{ :error_handler => lambda { |error, env_hash| ::ActivePublisher::Logging.logger.error(error.class) ::ActivePublisher::Logging.logger.error(error.) ::ActivePublisher::Logging.logger.error(error.backtrace.join("\n")) if error.backtrace.respond_to?(:join) }, :heartbeat => 5, :host => "localhost", :hosts => [], :port => 5672, :publisher_confirms => false, :seconds_to_wait_for_graceful_shutdown => 30, :timeout => 1, :username => "guest", :password => "guest", :virtual_host => "/" }
Instance Attribute Summary collapse
-
#error_handler ⇒ Object
Returns the value of attribute error_handler.
-
#heartbeat ⇒ Object
Returns the value of attribute heartbeat.
-
#host ⇒ Object
Returns the value of attribute host.
-
#hosts ⇒ Object
Returns the value of attribute hosts.
-
#password ⇒ Object
Returns the value of attribute password.
-
#port ⇒ Object
Returns the value of attribute port.
-
#publisher_confirms ⇒ Object
Returns the value of attribute publisher_confirms.
-
#seconds_to_wait_for_graceful_shutdown ⇒ Object
Returns the value of attribute seconds_to_wait_for_graceful_shutdown.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#username ⇒ Object
Returns the value of attribute username.
-
#virtual_host ⇒ Object
Returns the value of attribute virtual_host.
Class Method Summary collapse
Instance Method Summary collapse
- #connection_string=(url) ⇒ Object
-
#initialize ⇒ Configuration
constructor
Instance Methods.
Constructor Details
#initialize ⇒ Configuration
Instance Methods
76 77 78 79 80 |
# File 'lib/active_publisher/configuration.rb', line 76 def initialize DEFAULTS.each_pair do |key, value| self.__send__("#{key}=", value) end end |
Instance Attribute Details
#error_handler ⇒ Object
Returns the value of attribute error_handler.
5 6 7 |
# File 'lib/active_publisher/configuration.rb', line 5 def error_handler @error_handler end |
#heartbeat ⇒ Object
Returns the value of attribute heartbeat.
5 6 7 |
# File 'lib/active_publisher/configuration.rb', line 5 def heartbeat @heartbeat end |
#host ⇒ Object
Returns the value of attribute host.
5 6 7 |
# File 'lib/active_publisher/configuration.rb', line 5 def host @host end |
#hosts ⇒ Object
Returns the value of attribute hosts.
5 6 7 |
# File 'lib/active_publisher/configuration.rb', line 5 def hosts @hosts end |
#password ⇒ Object
Returns the value of attribute password.
5 6 7 |
# File 'lib/active_publisher/configuration.rb', line 5 def password @password end |
#port ⇒ Object
Returns the value of attribute port.
5 6 7 |
# File 'lib/active_publisher/configuration.rb', line 5 def port @port end |
#publisher_confirms ⇒ Object
Returns the value of attribute publisher_confirms.
5 6 7 |
# File 'lib/active_publisher/configuration.rb', line 5 def publisher_confirms @publisher_confirms end |
#seconds_to_wait_for_graceful_shutdown ⇒ Object
Returns the value of attribute seconds_to_wait_for_graceful_shutdown.
5 6 7 |
# File 'lib/active_publisher/configuration.rb', line 5 def seconds_to_wait_for_graceful_shutdown @seconds_to_wait_for_graceful_shutdown end |
#timeout ⇒ Object
Returns the value of attribute timeout.
5 6 7 |
# File 'lib/active_publisher/configuration.rb', line 5 def timeout @timeout end |
#username ⇒ Object
Returns the value of attribute username.
5 6 7 |
# File 'lib/active_publisher/configuration.rb', line 5 def username @username end |
#virtual_host ⇒ Object
Returns the value of attribute virtual_host.
5 6 7 |
# File 'lib/active_publisher/configuration.rb', line 5 def virtual_host @virtual_host end |
Class Method Details
.configure_from_yaml_and_cli(cli_options = {}, reload = false) ⇒ Object
Class Methods
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/active_publisher/configuration.rb', line 40 def self.configure_from_yaml_and_cli( = {}, reload = false) CONFIGURATION_MUTEX.synchronize do @configure_from_yaml_and_cli = nil if reload @configure_from_yaml_and_cli ||= begin env = ENV["RAILS_ENV"] || ENV["RACK_ENV"] || ENV["APP_ENV"] || "development" yaml_config = attempt_to_load_yaml_file DEFAULTS.each_pair do |key, value| setting = [key] || yaml_config[key.to_s] ::ActivePublisher.config.__send__("#{key}=", setting) if setting end true end end end |
Instance Method Details
#connection_string=(url) ⇒ Object
82 83 84 85 86 87 |
# File 'lib/active_publisher/configuration.rb', line 82 def connection_string=(url) settings = ::ActionSubscriber::URI.parse_amqp_url(url) settings.each do |key, value| send("#{key}=", value) end end |