Class: Parse::ACL
- Inherits:
-
Object
- Object
- Parse::ACL
- Defined in:
- lib/parse/acl.rb
Constant Summary collapse
- READ_ONLY =
{'read' => true}
- WRITE_ONLY =
{'write' => true}
- READ_WRITE =
{'read' => true, 'write' => true}
- NONE =
{}
- PUBLIC =
'*'- PUBLIC_READ_ONLY =
self.new PUBLIC => READ_ONLY
- PUBLIC_WRITE_ONLY =
self.new PUBLIC => WRITE_ONLY
- PUBLIC_READ_WRITE =
self.new PUBLIC => READ_WRITE
- PUBLIC_NONE =
self.new PUBLIC => NONE
Instance Method Summary collapse
-
#initialize(hash = {}, &block) ⇒ ACL
constructor
A new instance of ACL.
- #readable(user) ⇒ Object
- #readable?(user) ⇒ Boolean
- #to_json(*args) ⇒ Object
- #writable(user) ⇒ Object
- #writable?(user) ⇒ Boolean
Constructor Details
#initialize(hash = {}, &block) ⇒ ACL
Returns a new instance of ACL.
10 11 12 13 |
# File 'lib/parse/acl.rb', line 10 def initialize hash={}, &block @acl = hash.dup tap &block if block end |
Instance Method Details
#readable(user) ⇒ Object
15 16 17 |
# File 'lib/parse/acl.rb', line 15 def readable user (@acl[user] ||= {})['read'] = true end |
#readable?(user) ⇒ Boolean
19 20 21 |
# File 'lib/parse/acl.rb', line 19 def readable? user !!(@acl[user] ||= {})['read'] end |
#to_json(*args) ⇒ Object
31 32 33 |
# File 'lib/parse/acl.rb', line 31 def to_json *args @acl.to_json end |
#writable(user) ⇒ Object
23 24 25 |
# File 'lib/parse/acl.rb', line 23 def writable user (@acl[user] ||= {})['write'] = true end |
#writable?(user) ⇒ Boolean
27 28 29 |
# File 'lib/parse/acl.rb', line 27 def writable? user !!(@acl[user] ||= {})['write'] end |