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 collapse
- PARAM_NAMES =
:nodoc:
[:acl, :scope_type, :scope, :role, :title, :edit_url, :etag]
Constants included from Util
Util::DOCS_BASE_URL, Util::EXT_TO_CONTENT_TYPE
Instance Attribute Summary collapse
-
#params ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#initialize(params) ⇒ AclEntry
constructor
params
is a Hash object with keys:scope_type
,:scope
and:role
. - #inspect ⇒ Object
-
#role=(role) ⇒ Object
Changes the role of the scope.
Methods included from Util
concat_url, encode_query, h, to_v3_url
Constructor Details
#initialize(params) ⇒ AclEntry
params
is a Hash object with keys :scope_type
, :scope
and :role
. See scope_type and role for the document of the fields.
24 25 26 27 28 29 30 31 32 |
# File 'lib/google_drive/acl_entry.rb', line 24 def initialize(params) @params = {:role => "reader"} for name, value in params if !PARAM_NAMES.include?(name) raise(ArgumentError, "Invalid key: %p" % name) end @params[name] = value end end |
Instance Attribute Details
#params ⇒ Object
:nodoc:
34 35 36 |
# File 'lib/google_drive/acl_entry.rb', line 34 def params @params end |
Instance Method Details
#inspect ⇒ Object
50 51 52 53 |
# File 'lib/google_drive/acl_entry.rb', line 50 def inspect return "\#<%p scope_type=%p, scope=%p, role=%p>" % [self.class, @params[:scope_type], @params[:scope], @params[:role]] end |
#role=(role) ⇒ Object
Changes the role of the scope.
e.g.
spreadsheet.acl[1].role = "writer"
46 47 48 |
# File 'lib/google_drive/acl_entry.rb', line 46 def role=(role) @params[:acl].update_role(self, role) end |