Module: OnStomp::Failover::FailoverConfigurable::ClassMethods

Defined in:
lib/onstomp/failover/failover_configurable.rb

Overview

Provides attribute methods for failover clients.

Instance Method Summary collapse

Instance Method Details

#attr_configurable_bool(*args, &block) ⇒ Object

Creates readable and writeable attributes that are automatically converted into boolean values. Assigning the attributes any of true, ‘true’, ‘1’ or 1 will set the attribute to true, all other values with be treated as false. This method will also alias the reader methods with attr_name?



29
30
31
32
33
34
35
36
37
38
# File 'lib/onstomp/failover/failover_configurable.rb', line 29

def attr_configurable_bool *args, &block
  trans = attr_configurable_wrap lambda { |v|
    [true, 'true', '1', 1].include?(v) }, block
  attr_configurable_single(*args, &trans)
  args.each do |a|
    unless a.is_a?(Hash)
      alias_method :"#{a}?", a
    end
  end
end

#attr_configurable_buffer(nm) ⇒ Object

Creates a readable and writeable attribute with the given name that defaults to the Buffers::Written. Corresponds the the class to use for frame buffering and de-buffering.

Parameters:

  • nm (Symbol)

    name of attribute



56
57
58
59
60
61
# File 'lib/onstomp/failover/failover_configurable.rb', line 56

def attr_configurable_buffer nm
  attr_configurable_class(nm,
    :default => OnStomp::Failover::Buffers::Written) do |b|
    b || OnStomp::Failover::Buffers::Written
  end
end

#attr_configurable_int(*args, &block) ⇒ Object

Creates readable and writeable attributes that are automatically converted into integers.



19
20
21
22
# File 'lib/onstomp/failover/failover_configurable.rb', line 19

def attr_configurable_int *args, &block
  trans = attr_configurable_wrap lambda { |v| v.to_i }, block
  attr_configurable_single(*args, &trans)
end

#attr_configurable_pool(nm) ⇒ Object

Creates a readable and writeable attribute with the given name that defaults to the Pools::RoundRobin. Corresponds the the class to use when creating new client pools.

Parameters:

  • nm (Symbol)

    name of attribute



45
46
47
48
49
50
# File 'lib/onstomp/failover/failover_configurable.rb', line 45

def attr_configurable_pool nm
  attr_configurable_class(nm,
    :default => OnStomp::Failover::Pools::RoundRobin) do |p|
    p || OnStomp::Failover::Pools::RoundRobin
  end
end