module GoogleAppsOauth2::Atom::Node

Public Instance Methods

add_attributes(node, attributes) click to toggle source

add_attributes adds the specified attributes to the given node. It takes a LibXML::XML::Node and an array of name, value attribute pairs.

add_attribute node, [[‘title’, ‘emperor’], [‘name’, ‘Napoleon’]]

add_attribute returns the modified node.

# File lib/google_apps_oauth2/atom/node.rb, line 30
def add_attributes(node, attributes)
  attributes.each do |attribute|
    node.attributes[attribute[0]] = attribute[1]
  end

  node
end
check_value(value) click to toggle source

@param [String] value

@visibility public @return

# File lib/google_apps_oauth2/atom/node.rb, line 45
def check_value(value)
  case value
    when 'true'
      true
    when 'false'
      false
    else
      value
  end
end
create_node(properties) click to toggle source

create_node takes a hash of properties from which to build the XML node. The properties hash must have a :type key, it is also possible to pass an :attrs key with an array of attribute name, value pairs.

create_node type: ‘apps:property’, attrs: [[‘name’, ‘Tim’], [‘userName’, ‘tim@bob.com’]]

create_node returns an Atom::XML::Node with the specified properties.

# File lib/google_apps_oauth2/atom/node.rb, line 14
def create_node(properties)
  if properties[:attrs]
    add_attributes Atom::XML::Node.new(properties[:type]), properties[:attrs]
  else
    Atom::XML::Node.new properties[:type]
  end
end