Class: Zm::Client::Base::ObjectsCollection
- Inherits:
-
Object
- Object
- Zm::Client::Base::ObjectsCollection
show all
- Includes:
- Inspector
- Defined in:
- lib/zm/client/base/objects_collection.rb
Overview
Abstract Class Collection
Constant Summary
collapse
- METHODS_MISSING_LIST =
%i[select each map length].to_set.freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Inspector
#inspect, #instance_variables_map, #to_h, #to_s
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
57
58
59
60
61
62
63
|
# File 'lib/zm/client/base/objects_collection.rb', line 57
def method_missing(method, *, &)
if METHODS_MISSING_LIST.include?(method)
build_response.send(method, *, &)
else
super
end
end
|
Instance Attribute Details
Returns the value of attribute parent.
11
12
13
|
# File 'lib/zm/client/base/objects_collection.rb', line 11
def parent
@parent
end
|
Instance Method Details
#all ⇒ Object
Also known as:
all!
28
29
30
|
# File 'lib/zm/client/base/objects_collection.rb', line 28
def all
build_response
end
|
19
20
21
|
# File 'lib/zm/client/base/objects_collection.rb', line 19
def find(id)
find_by(id: id)
end
|
23
24
25
26
|
# File 'lib/zm/client/base/objects_collection.rb', line 23
def first
@limit = 1
build_response.first
end
|
69
70
71
|
# File 'lib/zm/client/base/objects_collection.rb', line 69
def logger
@parent.logger
end
|
#new {|child| ... } ⇒ Object
13
14
15
16
17
|
# File 'lib/zm/client/base/objects_collection.rb', line 13
def new
child = @child_class.new(@parent)
yield(child) if block_given?
child
end
|
#order(sort_by, sort_ascending = SoapUtils::ON) ⇒ Object
49
50
51
52
53
54
55
|
# File 'lib/zm/client/base/objects_collection.rb', line 49
def order(sort_by, sort_ascending = SoapUtils::ON)
return self if @sort_by == sort_by && @sort_ascending == sort_ascending
@sort_by = sort_by
@sort_ascending = sort_ascending
self
end
|
#page(offset) ⇒ Object
Also known as:
offset
41
42
43
44
45
46
|
# File 'lib/zm/client/base/objects_collection.rb', line 41
def page(offset)
return self if @offset == offset
@offset = offset
self
end
|
#per_page(limit) ⇒ Object
Also known as:
limit
33
34
35
36
37
38
|
# File 'lib/zm/client/base/objects_collection.rb', line 33
def per_page(limit)
return self if @limit == limit
@limit = limit
self
end
|
#respond_to_missing?(method) ⇒ Boolean
65
66
67
|
# File 'lib/zm/client/base/objects_collection.rb', line 65
def respond_to_missing?(method, *)
METHODS_MISSING_LIST.include?(method) || super
end
|