class GoogleSpreadsheet::Acl

ACL (access control list) of a spreadsheet.

Use GoogleSpreadsheet::Spreadsheet#acl to get GoogleSpreadsheet::Acl object. See GoogleSpreadsheet::Spreadsheet#acl for usage example.

This code is based on github.com/guyboertje/gdata-spreadsheet-ruby .

Public Instance Methods

[](index) click to toggle source

Returns GoogleSpreadsheet::AclEntry object at index.

# File doc_src/google_spreadsheet/acl.rb, line 10
def [](index)
end
delete(entry) click to toggle source

Deletes an ACL entry.

e.g.

spreadsheet.acl.delete(spreadsheet.acl[1])
# File lib/google_spreadsheet/acl.rb, line 72
def delete(entry)
  header = {"GData-Version" => "3.0"}
  @session.request(:delete, entry.edit_url, :header => header, :auth => :writely)
  @acls.delete(entry)
end
each() { |entry| ... } click to toggle source

Iterates over GoogleSpreadsheet::AclEntry objects.

# File doc_src/google_spreadsheet/acl.rb, line 14
def each(&block)
  yield(entry)
end
inspect() click to toggle source
# File lib/google_spreadsheet/acl.rb, line 103
def inspect
  return "\#<%p %p>" % [self.class, @acls]
end
push(entry) click to toggle source

Adds a new entry. entry is either a GoogleSpreadsheet::AclEntry or a Hash with keys :scope_type, :scope and :role. See GoogleSpreadsheet::AclEntry#scope_type and GoogleSpreadsheet::AclEntry#role for the document of the fields.

NOTE: This sends email to the new people.

e.g.

spreadsheet.acl.push(
    {:scope_type => "user", :scope => "example2@gmail.com", :role => "reader"})
spreadsheet.acl.push(
    {:scope_type => "user", :scope => "example3@gmail.com", :role => "writer"})
# File lib/google_spreadsheet/acl.rb, line 43
        def push(entry)
          
          entry = AclEntry.new(entry) if entry.is_a?(Hash)
          
          header = {"GData-Version" => "3.0", "Content-Type" => "application/atom+xml"}
          value_attr = entry.scope ? "value='#{h(entry.scope)}'" : ""
          xml = "            <entry
                xmlns='http://www.w3.org/2005/Atom'
                xmlns:gAcl='http://schemas.google.com/acl/2007'>
              <category scheme='http://schemas.google.com/g/2005#kind'
                  term='http://schemas.google.com/acl/2007#accessRule'/>
              <gAcl:role value='#{h(entry.role)}'/>
              <gAcl:scope type='#{h(entry.scope_type)}' #{value_attr}/>
            </entry>
"
          doc = @session.request(
              :post, @acls_feed_url, :data => xml, :header => header, :auth => :writely)
          
          entry.params = entry_to_params(doc.root)
          @acls.push(entry)
          return entry
          
        end
size() click to toggle source

Returns the number of entries.

# File doc_src/google_spreadsheet/acl.rb, line 6
def size
end