Class: GoogleApps::Atom::Group
- Defined in:
- lib/google_apps/atom/group.rb
Constant Summary collapse
- MAP =
{ groupId: :id, groupName: :name, emailPermission: :permission, description: :description }
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#permissions ⇒ Object
Returns the value of attribute permissions.
Instance Method Summary collapse
- #change_value(name, old_value, new_value) ⇒ Object
-
#initialize(xml = nil) ⇒ Group
constructor
A new instance of Group.
-
#new_group(group_data) ⇒ Object
new_group populates the Group XML document with the provided values.
-
#set_values(group_values) ⇒ Object
set_values will add the specified group attributes to @doc.
-
#to_s ⇒ Object
to_s returns @doc as a String.
Methods inherited from Document
add_type, #attrs_from_props, #build_root, #delete_node, #determine_namespaces, #find_and_update, #find_values, inherited, #make_document, #new_empty_doc, #parse, #set_instances, sub_to_meth, #type_to_s, #type_to_sym, types
Methods included from Node
#add_attributes, #add_namespaces, #add_prop_node, #check_value, #create_node, #get_content, #get_values, #node_match?
Constructor Details
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/google_apps/atom/group.rb', line 4 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/google_apps/atom/group.rb', line 4 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/google_apps/atom/group.rb', line 4 def name @name end |
#permissions ⇒ Object
Returns the value of attribute permissions.
4 5 6 |
# File 'lib/google_apps/atom/group.rb', line 4 def @permissions end |
Instance Method Details
#change_value(name, old_value, new_value) ⇒ Object
53 54 55 |
# File 'lib/google_apps/atom/group.rb', line 53 def change_value(name, old_value, new_value) find_and_update '//apps:property', { name => [old_value, new_value] } end |
#new_group(group_data) ⇒ Object
new_group populates the Group XML document with the provided values. new_group accepts a hash with the following keys: id, name, description and perms. id and name are required for a call to new_group.
new_group id: ‘ID’, name: ‘Name’, description: ‘Group Description’,
perms: 'emailPermissions'
new_group returns @doc.root
28 29 30 31 |
# File 'lib/google_apps/atom/group.rb', line 28 def new_group(group_data) [:id, :name].each { |attr| raise(ArgumentError, "Missing or Invalid Parameter(s)") unless group_data.key?(attr) } set_values group_data end |
#set_values(group_values) ⇒ Object
set_values will add the specified group attributes to @doc. set_values accepts a hash with any of the following keys: id:, name:, description:, perms:
set_values id: ‘blah’, description: ‘Unexciting and uninspired’
set_values returns @doc.root
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/google_apps/atom/group.rb', line 41 def set_values(group_values) group_values.keys.each do |key| prop = Atom::XML::Node.new('apps:property') prop_name(prop, key) prop.attributes['value'] = group_values[key] @doc.root << prop end @doc.root end |
#to_s ⇒ Object
to_s returns @doc as a String.
91 92 93 |
# File 'lib/google_apps/atom/group.rb', line 91 def to_s @doc.to_s end |