Class: Zm::Client::ContactMembersCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/zm/client/contact/contact_members_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ ContactMembersCollection

Returns a new instance of ContactMembersCollection.



8
9
10
11
# File 'lib/zm/client/contact/contact_members_collection.rb', line 8

def initialize(parent)
  @parent = parent
  @all = []
end

Instance Attribute Details

#allObject

Returns the value of attribute all.



6
7
8
# File 'lib/zm/client/contact/contact_members_collection.rb', line 6

def all
  @all
end

Instance Method Details

#add(new_member) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/zm/client/contact/contact_members_collection.rb', line 13

def add(new_member)
  return false unless new_member.is_a?(Zm::Client::ConcatMember)

  current_member = @all.find { |m| m.type == new_member.type && m.value == new_member.value }

  if current_member.nil?
    new_member.add!
    @all << new_member
    return true
  end

  if current_member.op == Zm::Client::ConcatMember::DEL
    current_member.add!
    return true
  end

  false
end

#remove(new_member) ⇒ Object



32
33
34
35
36
37
38
39
40
41
# File 'lib/zm/client/contact/contact_members_collection.rb', line 32

def remove(new_member)
  return false unless new_member.is_a?(Zm::Client::ConcatMember)

  current_member = @all.find { |m| m.type == new_member.type && m.value == new_member.value }
  return false if current_member.nil?

  current_member.remove!

  true
end