Class: AdobeConnect::AclField

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

Overview

Public: Represents a Custom Field object inside of Connect.

Instance Attribute Summary collapse

Attributes inherited from Base

#errors

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#ac_obj_node_name, #ac_obj_type, 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

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#obj_typeObject

Returns the value of attribute obj_type.



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

def obj_type
  @obj_type
end

#serviceObject

Returns the value of attribute service.



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

def service
  @service
end

Class Method Details

.configObject



27
28
29
# File 'lib/adobe_connect/acl_field.rb', line 27

def self.config
  super.merge({ :ac_obj_type => 'field', :ac_method_prefix => 'custom_field' })
end

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

Public: Find a folder on the current Connect instance.

name, obj_type, service - see #attrs for description

Returns a new AdobeConnect::AclField object.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/adobe_connect/acl_field.rb', line 36

def self.find_or_create(name, obj_type, service = AdobeConnect::Service.new)
  response = service.custom_fields(:filter_name => name)
  c_flds = response.at_xpath('//custom-fields').children

  if c_flds.count.zero?
    #Create
    fld = self.new({ :name => name, :obj_type => obj_type }, service)
    fld.save
  else
    fld = load_from_xml(c_flds[0])
  end

  fld
end

.load_from_xml(ac_field, service) ⇒ Object (private)



52
53
54
55
56
57
58
# File 'lib/adobe_connect/acl_field.rb', line 52

def self.load_from_xml(ac_field, service)
  self.new({
      :id => ac_field.attr('field-id'),
      :name => ac_field.at_xpath('//name').text,
      :obj_type => ac_field.attr('obj_type')
    }, service)
end

Instance Method Details

#attrsObject

id - The Field-ID of the custom field object. name - The name of the Field. obj_type- The type of Connect Object this applies to. Allowed values

are: principal, meeting, sco, event, read-only


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

def attrs
  atrs = {
    :object_type => "object-type-#{obj_type}", :permission_id => 'manage',
    :name => name, :field_type => 'text', :is_required => false,
    :is_primary => true
  }

  if !id.nil?
    atrs.merge!(:field_id => id)
  end

  atrs
end