Class: AdobeConnect::Base
- Inherits:
-
Object
- Object
- AdobeConnect::Base
- Defined in:
- lib/adobe_connect/base.rb
Overview
Provides base interaction with Adobe Connect for a variety of AC Objects
Direct Known Subclasses
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#id ⇒ Object
Public: SCO-ID from the Adobe Connect instance.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
Class Method Summary collapse
- .config ⇒ Object
-
.create(obj_options) ⇒ Object
Public: Create a Connect obj from the given app obj.
Instance Method Summary collapse
- #ac_obj_node_name ⇒ Object private
- #ac_obj_type ⇒ Object private
- #attrs ⇒ Object
-
#delete ⇒ Object
Public: Delete this object form Adobe Connect.
- #delete_method_prefix ⇒ Object private
-
#initialize(obj_options, service = Service.new) ⇒ Base
constructor
A new instance of Base.
- #method_prefix ⇒ Object private
-
#permissions_update(principal_id, permission_id) ⇒ Object
Public: Update permissions on the loaded object for the given principal_id.
-
#save ⇒ Object
Public: Save this object to the Adobe Connect instance.
-
#save_errors(response) ⇒ Object
private
Internal: Store request errors in @errors.
-
#set_attrs(atrs) ⇒ Object
private
Internal: Update attributes from an attribute hash.
-
#update_attributes(atrs) ⇒ Object
Public: Update attributes of the loaded object and save.
Constructor Details
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
8 9 10 |
# File 'lib/adobe_connect/base.rb', line 8 def errors @errors end |
#id ⇒ Object
Public: SCO-ID from the Adobe Connect instance.
6 7 8 |
# File 'lib/adobe_connect/base.rb', line 6 def id @id end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
8 9 10 |
# File 'lib/adobe_connect/base.rb', line 8 def service @service end |
Class Method Details
.config ⇒ Object
84 85 86 |
# File 'lib/adobe_connect/base.rb', line 84 def self.config { :ac_obj_type => 'principal', :delete_method_is_plural => true } end |
.create(obj_options) ⇒ Object
Public: Create a Connect obj from the given app obj.
obj_options - Generic options (see #initialize for required
attributes).
Returns an instance of this class, with an attempted save.
77 78 79 80 81 82 |
# File 'lib/adobe_connect/base.rb', line 77 def self.create() obj = self.new() obj.save obj end |
Instance Method Details
#ac_obj_node_name ⇒ Object (private)
91 92 93 |
# File 'lib/adobe_connect/base.rb', line 91 def ac_obj_node_name self.class.config[:ac_obj_node_name] || ac_obj_type end |
#ac_obj_type ⇒ Object (private)
95 96 97 |
# File 'lib/adobe_connect/base.rb', line 95 def ac_obj_type self.class.config[:ac_obj_type] end |
#attrs ⇒ Object
16 17 18 |
# File 'lib/adobe_connect/base.rb', line 16 def attrs {} end |
#delete ⇒ Object
Public: Delete this object form Adobe Connect.
Returns a boolean.
23 24 25 26 |
# File 'lib/adobe_connect/base.rb', line 23 def delete response = service.send(:"#{delete_method_prefix}_delete", {:"#{ac_obj_type}_id" => self.id}) response.at_xpath('//status').attr('code') == 'ok' end |
#delete_method_prefix ⇒ Object (private)
99 100 101 102 103 |
# File 'lib/adobe_connect/base.rb', line 99 def delete_method_prefix prefix = method_prefix prefix = prefix.pluralize if self.class.config[:delete_method_is_plural] prefix end |
#method_prefix ⇒ Object (private)
105 106 107 |
# File 'lib/adobe_connect/base.rb', line 105 def method_prefix self.class.config[:ac_method_prefix] || ac_obj_type end |
#permissions_update(principal_id, permission_id) ⇒ Object
Public: Update permissions on the loaded object for the given principal_id.
principal_id - id of user permission_id - AdobeConnect permission value
Returns a boolean.
61 62 63 64 65 66 67 68 69 |
# File 'lib/adobe_connect/base.rb', line 61 def (principal_id, ) response = service.( acl_id: self.id, principal_id: principal_id, permission_id: ) response.at_xpath('//status').attr('code') == 'ok' end |
#save ⇒ Object
Public: Save this object to the Adobe Connect instance.
Returns a boolean.
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/adobe_connect/base.rb', line 31 def save response = service.send(:"#{method_prefix}_update", self.attrs) if response.at_xpath('//status').attr('code') == 'ok' # Load the ID if this was a creation self.id = response.at_xpath("//#{ac_obj_node_name}").attr("#{ac_obj_type}-id") if self.id.nil? true else save_errors(response) false end end |
#save_errors(response) ⇒ Object (private)
Internal: Store request errors in @errors.
response - An AdobeConnect::Response.
Returns nothing.
114 115 116 |
# File 'lib/adobe_connect/base.rb', line 114 def save_errors(response) @errors = response.xpath('//invalid').map(&:attributes) end |
#set_attrs(atrs) ⇒ Object (private)
Internal: Update attributes from an attribute hash
atrs - A hash of keys that match attributes of this object and
corresponding values for those attributes.
Returns nothing.
124 125 126 |
# File 'lib/adobe_connect/base.rb', line 124 def set_attrs(atrs) atrs.each { |key, value| send(:"#{key}=", value) } end |
#update_attributes(atrs) ⇒ Object
Public: Update attributes of the loaded object and save.
atrs - Generic options (see #initialize for required
attributes).
Returns a boolean.
50 51 52 53 |
# File 'lib/adobe_connect/base.rb', line 50 def update_attributes(atrs) set_attrs(atrs) self.save end |