Class: AdobeConnect::Group

Inherits:
Base
  • Object
show all
Defined in:
lib/adobe_connect/group.rb

Overview

Public: Represents a Group in a Connect environment.

Instance Attribute Summary collapse

Attributes inherited from Base

#errors, #service

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#ac_obj_node_name, #ac_obj_type, config, create, #delete, #delete_method_prefix, #initialize, #method_prefix, #permissions_update, #save, #save_errors, #set_attrs, #update_attributes

Constructor Details

This class inherits a constructor from AdobeConnect::Base

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



5
6
7
# File 'lib/adobe_connect/group.rb', line 5

def description
  @description
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/adobe_connect/group.rb', line 5

def id
  @id
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/adobe_connect/group.rb', line 5

def name
  @name
end

Class Method Details

.find_by_name(name, service = AdobeConnect::Service.new) ⇒ Object

Public: Find the given group on the Connect server.

name - Group’s name on Connect server

Returns an AdobeConnect::Group or nil.



64
65
66
67
68
69
70
# File 'lib/adobe_connect/group.rb', line 64

def self.find_by_name(name, service = AdobeConnect::Service.new)
  response = service.principal_list(:filter_name => name)

  if principal = response.at_xpath('//principal')
    self.load_from_xml(principal)
  end
end

.load_from_xml(g) ⇒ Object (private)



83
84
85
86
87
88
89
90
91
92
# File 'lib/adobe_connect/group.rb', line 83

def self.load_from_xml(g)
  desc = g.at_xpath('//description')
  desc = desc.children unless desc.nil?
  desc = desc.text unless desc.nil?
  self.new({
      :name => g.at_xpath('//name').children.text,
      :description => desc,
      :id => g.attr('principal-id')
    })
end

Instance Method Details

#add_member(user) ⇒ Object

Public: Add a User as a member of this group.

user - AdobeConnect::User instance

Returns a boolean of success.



31
32
33
# File 'lib/adobe_connect/group.rb', line 31

def add_member(user)
  update_membership(user, true)
end

#attrsObject

group_options - A hash with the following keys:

name        - The group’s name.
description - The group's description


13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/adobe_connect/group.rb', line 13

def attrs
  atrs = { :has_children => 1, :name => name, :description => description }

  if !self.id.nil?
    atrs.merge!(:principal_id => self.id)
  else
    atrs.merge!(
      :type => 'group'
    )
  end
  atrs
end

#is_member?(email) ⇒ Boolean

Public: Find the member of this group.

email - User’s email address

Returns a boolean.

Returns:

  • (Boolean)


40
41
42
43
44
45
46
47
48
# File 'lib/adobe_connect/group.rb', line 40

def is_member?(email)
  return false if self.id.nil?

  response = service.principal_list(:group_id => self.id,
    :filter_email => email,
    :filter_is_member => true)

  !response.at_xpath('//principal').nil?
end

#remove_member(user) ⇒ Object

Public: Remove a User from this group.

user - AdobeConnect::User instance

Returns a boolean of success.



55
56
57
# File 'lib/adobe_connect/group.rb', line 55

def remove_member(user)
  update_membership(user, false)
end

#update_membership(user, status) ⇒ Object (private)



73
74
75
76
77
78
79
80
81
# File 'lib/adobe_connect/group.rb', line 73

def update_membership(user, status)
  response = service.group_membership_update({
      :group_id => self.id,
      :principal_id => user.id,
      :is_member => status
    })

  response.at_xpath('//status').attr('code') == 'ok'
end