Class: Zm::Client::MtaQueuesCollection

Inherits:
Base::ObjectsCollection show all
Defined in:
lib/zm/client/mta_queue/mta_queues_collection.rb

Overview

Collection MtaQueues

Constant Summary

Constants inherited from Base::ObjectsCollection

Base::ObjectsCollection::METHODS_MISSING_LIST

Instance Attribute Summary

Attributes inherited from Base::ObjectsCollection

#parent

Instance Method Summary collapse

Methods inherited from Base::ObjectsCollection

#all, #all!, #first, #logger, #method_missing, #new, #order, #page, #per_page, #respond_to_missing?

Methods included from Inspector

#inspect, #instance_variables_map, #to_h, #to_s

Constructor Details

#initialize(parent) ⇒ MtaQueuesCollection

Returns a new instance of MtaQueuesCollection.



7
8
9
10
# File 'lib/zm/client/mta_queue/mta_queues_collection.rb', line 7

def initialize(parent)
  @parent = parent
  reset_query_params
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Zm::Client::Base::ObjectsCollection

Instance Method Details

#defaultsObject



12
13
14
# File 'lib/zm/client/mta_queue/mta_queues_collection.rb', line 12

def defaults
  @all || defaults!
end

#defaults!Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/zm/client/mta_queue/mta_queues_collection.rb', line 16

def defaults!
  Zm::Client::MtaQueueName::ALL.each do |queue_name|
    queue = MtaQueue.new(@parent)
    queue.name = queue_name
    set_dynamic_queue_method(queue)
    @queues_h[queue_name] = queue
  end

  @all = @queues_h.values
end

#find(queue_name) ⇒ Object

Raises:



27
28
29
30
31
32
# File 'lib/zm/client/mta_queue/mta_queues_collection.rb', line 27

def find(queue_name)
  raise ZmError, 'Unknown queue name' unless Zm::Client::MtaQueueName::ALL.include?(queue_name)

  all! if @queues_h.empty?
  @queues_h[queue_name]
end