Class: Escobar::Heroku::User

Inherits:
Object
  • Object
show all
Defined in:
lib/escobar/heroku/user.rb

Overview

Class representing the owner of the token

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#clientObject (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

Returns:

  • (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

Returns:

  • (Boolean)


10
11
12
# File 'lib/escobar/heroku/user.rb', line 10

def can_view_app?(app_id)
  can?("app", app_id, "view")
end