Class: Uploader::AuthorizationAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/uploader/authorization_adapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ AuthorizationAdapter

Initialize a new authorization adapter. This happens on each and every request to a controller.



9
10
11
# File 'lib/uploader/authorization_adapter.rb', line 9

def initialize(user)
  @user = user
end

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user.



5
6
7
# File 'lib/uploader/authorization_adapter.rb', line 5

def user
  @user
end

Instance Method Details

#authorized?(action, subject = nil) ⇒ Boolean

Returns true of false depending on if the user is authorized to perform the action on the subject.

Returns:

  • (Boolean)


15
16
17
# File 'lib/uploader/authorization_adapter.rb', line 15

def authorized?(action, subject = nil)
  true
end

#scope_collection(collection, action = :index) ⇒ Object

A hook method for authorization libraries to scope the collection. By default, we just return the same collection. The returned scope is used as the starting point for all queries to the db in the controller.



22
23
24
# File 'lib/uploader/authorization_adapter.rb', line 22

def scope_collection(collection, action = :index)
  collection
end