Class: Msgraph::Api::Resource::List

Inherits:
Base
  • Object
show all
Defined in:
lib/msgraph/api/resource/list.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#attributes, #parent, #resource_name

Instance Method Summary collapse

Methods inherited from Base

#client, lists, #method_missing, resource_name, #user

Constructor Details

#initialize(parent, clazz, resource_name) ⇒ List

Returns a new instance of List.



8
9
10
11
# File 'lib/msgraph/api/resource/list.rb', line 8

def initialize(parent, clazz, resource_name)
  super(parent, resource_name: resource_name)
  @child_class = clazz
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Msgraph::Api::Resource::Base

Instance Attribute Details

#child_classObject (readonly)

Returns the value of attribute child_class.



6
7
8
# File 'lib/msgraph/api/resource/list.rb', line 6

def child_class
  @child_class
end

Instance Method Details

#eachObject



21
22
23
24
25
26
27
28
# File 'lib/msgraph/api/resource/list.rb', line 21

def each
  next_link = first_link
  while !next_link.nil?
    next_link = page_for(next_link) do |elements|
      elements.each{|e| yield e}
    end
  end
end

#empty?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/msgraph/api/resource/list.rb', line 39

def empty?
  size == 0
end

#find(id) ⇒ Object



17
18
19
# File 'lib/msgraph/api/resource/list.rb', line 17

def find(id)
  child_class.new(self, resource_name: resource_name, id: id)
end

#resource_pathObject



13
14
15
# File 'lib/msgraph/api/resource/list.rb', line 13

def resource_path
  parent.resource_path
end

#sizeObject



30
31
32
33
34
35
36
37
# File 'lib/msgraph/api/resource/list.rb', line 30

def size
  if @size.nil?
    page_for(first_link) do |_, size|
      @size ||= size
    end
  end
  @size
end