Class: GoogleDrive::AclEntry

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/google_drive/acl_entry.rb

Overview

An entry of an ACL (access control list) of a spreadsheet.

Use GoogleDrive::Acl#[] to get GoogleDrive::AclEntry object.

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

Constant Summary

Constants included from Util

Util::EXT_TO_CONTENT_TYPE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

concat_url, construct_and_query, construct_query, convert_params, delegate_api_methods, encode_query, h, new_upload_io, singleton_class

Constructor Details

#initialize(params_or_api_permission, acl = nil) ⇒ AclEntry

params_or_api_permission is a Hash object with keys :type, :value, :role and :withLink. See GoogleDrive::Acl#push for description of the parameters.



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/google_drive/acl_entry.rb', line 20

def initialize(params_or_api_permission, acl = nil)
  @acl = acl
  if acl
    @api_permission = params_or_api_permission
    @params = nil
    delegate_api_methods(self, @api_permission)
  else
    @api_permission = nil
    @params = convert_params(params_or_api_permission)
  end
end

Instance Attribute Details

#aclObject (readonly)

Returns the value of attribute acl.



32
33
34
# File 'lib/google_drive/acl_entry.rb', line 32

def acl
  @acl
end

#api_permissionObject

:nodoc:



34
35
36
# File 'lib/google_drive/acl_entry.rb', line 34

def api_permission
  @api_permission
end

#paramsObject (readonly)

:nodoc:



33
34
35
# File 'lib/google_drive/acl_entry.rb', line 33

def params
  @params
end

Instance Method Details

#additional_rolesObject



56
57
58
# File 'lib/google_drive/acl_entry.rb', line 56

def additional_roles
  return @params ? @params["additionalRoles"] : @api_permission.additional_roles
end

#idObject



60
61
62
# File 'lib/google_drive/acl_entry.rb', line 60

def id
  return @params ? @params["id"] : @api_permission.id
end

#inspectObject



91
92
93
94
# File 'lib/google_drive/acl_entry.rb', line 91

def inspect
  return "\#<%p type=%p, name=%p, role=%p>" %
      [self.class, self.type, self.name, self.role]
end

#roleObject

The role given to the scope. One of:

  • “owner”: The owner.

  • “writer”: With read/write access.

  • “reader”: With read-only access.



40
41
42
# File 'lib/google_drive/acl_entry.rb', line 40

def role
  return @params ? @params["role"] : @api_permission.role
end

#role=(role) ⇒ Object

Changes the role of the scope.

e.g.

spreadsheet.acl[1].role = "writer"


82
83
84
85
86
87
88
89
# File 'lib/google_drive/acl_entry.rb', line 82

def role=(role)
  if @params
    @params["role"] = role
  else
    @api_permission.role = role
    @acl.update_role(self)
  end
end

#typeObject Also known as: scope_type

Type of the scope. One of:

  • “user”: value is a user’s email address.

  • “group”: value is a Google Group email address.

  • “domain”: value is a Google Apps domain.

  • “anyone”: Publicly shared with all users. value is nil.



50
51
52
# File 'lib/google_drive/acl_entry.rb', line 50

def type
  return @params ? @params["type"] : @api_permission.type
end

#valueObject Also known as: scope

The value of the scope. See type.



65
66
67
# File 'lib/google_drive/acl_entry.rb', line 65

def value
  return @params ? @params["value"] : @api_permission.value
end

If true, the file is shared only with people who know the link.



72
73
74
# File 'lib/google_drive/acl_entry.rb', line 72

def with_link
  return @params ? @params["withLink"] : @api_permission.with_link
end