Class: Avo::Services::AuthorizationService

Inherits:
Object
  • Object
show all
Defined in:
lib/avo/services/authorization_service.rb

Defined Under Namespace

Classes: NilPolicy

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user = nil, record = nil, policy_class: nil) ⇒ AuthorizationService

Returns a new instance of AuthorizationService.



18
19
20
21
22
# File 'lib/avo/services/authorization_service.rb', line 18

def initialize(user = nil, record = nil, policy_class: nil)
  @user = user
  @record = record
  @policy_class = NilPolicy
end

Instance Attribute Details

#policy_classObject

Returns the value of attribute policy_class.



6
7
8
# File 'lib/avo/services/authorization_service.rb', line 6

def policy_class
  @policy_class
end

#recordObject

Returns the value of attribute record.



5
6
7
# File 'lib/avo/services/authorization_service.rb', line 5

def record
  @record
end

#userObject

Returns the value of attribute user.



4
5
6
# File 'lib/avo/services/authorization_service.rb', line 4

def user
  @user
end

Class Method Details

.apply_policy(user, query) ⇒ Object



13
14
15
# File 'lib/avo/services/authorization_service.rb', line 13

def apply_policy(user, query)
  query
end

.authorize(*args, **kwargs) ⇒ Object



9
10
11
# File 'lib/avo/services/authorization_service.rb', line 9

def authorize(*args, **kwargs)
  true
end

Instance Method Details

#apply_policy(query) ⇒ Object



30
31
32
# File 'lib/avo/services/authorization_service.rb', line 30

def apply_policy(query)
  query
end

#authorize_action(*args) ⇒ Object



34
35
36
# File 'lib/avo/services/authorization_service.rb', line 34

def authorize_action(*args)
  true
end

#has_method?(*args, **kwargs) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/avo/services/authorization_service.rb', line 38

def has_method?(*args, **kwargs)
  false
end

#set_record(record) ⇒ Object



24
25
26
27
28
# File 'lib/avo/services/authorization_service.rb', line 24

def set_record(record)
  @record = record

  self
end