Class: Escobar::Heroku::User
- Inherits:
-
Object
- Object
- Escobar::Heroku::User
- Defined in:
- lib/escobar/heroku/user.rb
Overview
Class representing the owner of the token
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #can?(resource_type, resource_id, capability) ⇒ Boolean
- #can_view_app?(app_id) ⇒ Boolean
-
#initialize(client) ⇒ User
constructor
A new instance of User.
Constructor Details
#initialize(client) ⇒ User
Returns a new instance of User.
6 7 8 |
# File 'lib/escobar/heroku/user.rb', line 6 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/escobar/heroku/user.rb', line 5 def client @client end |
Instance Method Details
#can?(resource_type, resource_id, capability) ⇒ Boolean
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/escobar/heroku/user.rb', line 14 def can?(resource_type, resource_id, capability) body = { resource_type: resource_type, resource_id: resource_id, capability: capability } response = client.put("/users/~/capabilities", body, nil, "3.capabilities") response["capabilities"][0]["capable"] end |
#can_view_app?(app_id) ⇒ Boolean
10 11 12 |
# File 'lib/escobar/heroku/user.rb', line 10 def can_view_app?(app_id) can?("app", app_id, "view") end |