Class: Adhearsion::Asterisk::ConfigGenerator::Queues

Inherits:
Adhearsion::Asterisk::ConfigGenerator show all
Defined in:
lib/adhearsion/asterisk/config_generator/queues.rb

Overview

This will generate a queues.conf file. If there is no documentation on what a method actually does, take a look at the documentation for its original key/value pair in an unedited queues.conf file. WARNING! Don't get too embedded with these method names. I'm still not satisfied. These settings will be greatly abstracted eventually.

Defined Under Namespace

Classes: QueueDefinition

Constant Summary

DEFAULT_GENERAL_SECTION =
{
  :autofill => "yes"
}

Constants inherited from Adhearsion::Asterisk::ConfigGenerator

SECTION_TITLE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Adhearsion::Asterisk::ConfigGenerator

create_sanitary_hash_from, #to_sanitary_hash, warning_message

Constructor Details

#initializeQueues



17
18
19
20
21
22
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 17

def initialize
  @general_section   = DEFAULT_GENERAL_SECTION.clone
  @properties        = {}
  @queue_definitions = []
  super
end

Instance Attribute Details

#general_sectionObject (readonly)

Returns the value of attribute general_section



16
17
18
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 16

def general_section
  @general_section
end

#propertiesObject (readonly)

Returns the value of attribute properties



16
17
18
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 16

def properties
  @properties
end

#queue_definitionsObject (readonly)

Returns the value of attribute queue_definitions



16
17
18
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 16

def queue_definitions
  @queue_definitions
end

Instance Method Details

#monitor_type(symbol) ⇒ Object



42
43
44
45
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 42

def monitor_type(symbol)
  criteria = {:monitor => "Monitor", :mix_monitor => "MixMonitor"}
  one_of_and_translate criteria, 'monitor-type' => symbol, :with => general_section
end

#persistent_members(yes_no) ⇒ Object



38
39
40
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 38

def persistent_members(yes_no)
  boolean :persistentmembers => yes_no, :with => general_section
end

#queue(name) {|new_queue| ... } ⇒ Object

Yields:

  • (new_queue)


24
25
26
27
28
29
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 24

def queue(name)
  new_queue = QueueDefinition.new name
  yield new_queue if block_given?
  queue_definitions << new_queue
  new_queue
end

#to_sObject Also known as: conf



31
32
33
34
35
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 31

def to_s
  ConfigGenerator.warning_message +
  general_section.inject("[general]") { |section,(key,value)| section + "\n#{key}=#{value}" } + "\n\n" +
  queue_definitions.map(&:to_s).join("\n\n")
end