Class: GoogleDrive::AclEntry
- Inherits:
-
Object
- Object
- GoogleDrive::AclEntry
- 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
Instance Attribute Summary collapse
-
#acl ⇒ Object
readonly
Returns the value of attribute acl.
-
#api_permission ⇒ Object
:nodoc:.
-
#params ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
- #additional_roles ⇒ Object
- #id ⇒ Object
-
#initialize(params_or_api_permission, acl = nil) ⇒ AclEntry
constructor
params_or_api_permission
is a Hash object with keys:type
,:value
,:role
and:withLink
. - #inspect ⇒ Object
-
#role ⇒ Object
The role given to the scope.
-
#role=(role) ⇒ Object
Changes the role of the scope.
-
#type ⇒ Object
(also: #scope_type)
Type of the scope.
-
#value ⇒ Object
(also: #scope)
The value of the scope.
-
#with_link ⇒ Object
(also: #with_key)
If
true
, the file is shared only with people who know the link.
Methods included from Util
concat_url, construct_and_query, construct_query, convert_params, delegate_api_methods, encode_query, get_singleton_class, h, new_upload_io
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(, acl = nil) @acl = acl if acl @api_permission = @params = nil delegate_api_methods(self, @api_permission, ["value"]) else @api_permission = nil @params = convert_params() end end |
Instance Attribute Details
#acl ⇒ Object (readonly)
Returns the value of attribute acl.
32 33 34 |
# File 'lib/google_drive/acl_entry.rb', line 32 def acl @acl end |
#api_permission ⇒ Object
:nodoc:
34 35 36 |
# File 'lib/google_drive/acl_entry.rb', line 34 def @api_permission end |
#params ⇒ Object (readonly)
:nodoc:
33 34 35 |
# File 'lib/google_drive/acl_entry.rb', line 33 def params @params end |
Instance Method Details
#additional_roles ⇒ Object
56 57 58 |
# File 'lib/google_drive/acl_entry.rb', line 56 def additional_roles return @params ? @params["additionalRoles"] : @api_permission.additional_roles end |
#id ⇒ Object
60 61 62 |
# File 'lib/google_drive/acl_entry.rb', line 60 def id return @params ? @params["id"] : @api_permission.id end |
#inspect ⇒ Object
102 103 104 105 |
# File 'lib/google_drive/acl_entry.rb', line 102 def inspect return "\#<%p type=%p, name=%p, role=%p>" % [self.class, self.type, self.name, self.role] end |
#role ⇒ Object
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"
93 94 95 96 97 98 99 100 |
# File 'lib/google_drive/acl_entry.rb', line 93 def role=(role) if @params @params["role"] = role else @api_permission.role = role @acl.update_role(self) end end |
#type ⇒ Object 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 |
#value ⇒ Object Also known as: scope
The value of the scope. See type.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/google_drive/acl_entry.rb', line 65 def value if @params return @params["value"] else case @api_permission.type when "user", "group" return @api_permission.email_address when "domain" return @api_permission.domain else return nil end end end |
#with_link ⇒ Object Also known as: with_key
If true
, the file is shared only with people who know the link.
83 84 85 |
# File 'lib/google_drive/acl_entry.rb', line 83 def with_link return @params ? @params["withLink"] : @api_permission.with_link end |