Class: RFlow::Configuration::Connection

Inherits:
ConfigurationItem show all
Includes:
ActiveModel::Validations, UUIDKeyed
Defined in:
lib/rflow/configuration/connection.rb

Direct Known Subclasses

BrokeredZMQConnection, ZMQConnection

Defined Under Namespace

Classes: ConnectionInvalid

Class Method Summary collapse

Instance Method Summary collapse

Methods included from UUIDKeyed

included

Class Method Details

.default_optionsObject

Should return a hash of default options, where the keys are the option names and the values are either default option values or Procs that take a single connection argument. This allow defaults to use other parameters in the connection to construct the appropriate default value.



48
# File 'lib/rflow/configuration/connection.rb', line 48

def self.default_options; {}; end

.required_optionsObject

Should return a list of require option names which will be used in validations. To be overridden.



41
# File 'lib/rflow/configuration/connection.rb', line 41

def self.required_options; []; end

Instance Method Details

#all_required_options_present?Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
# File 'lib/rflow/configuration/connection.rb', line 24

def all_required_options_present?
  self.class.required_options.each do |option_name|
    unless self.options.include? option_name.to_s
      errors.add(:options, "must include #{option_name} for #{self.class.to_s}")
    end
  end
end

#brokersObject

By default, no broker processes are required to manage a connection.



51
# File 'lib/rflow/configuration/connection.rb', line 51

def brokers; []; end

#merge_default_options!Object



32
33
34
35
36
37
# File 'lib/rflow/configuration/connection.rb', line 32

def merge_default_options!
  self.options ||= {}
  self.class.default_options.each do |name, default_value_or_proc|
    self.options[name.to_s] ||= default_value_or_proc.is_a?(Proc) ? default_value_or_proc.call(self) : default_value_or_proc
  end
end