Class: ResourcePolicy

Inherits:
Object
  • Object
show all
Defined in:
app/policies/resource_policy.rb

Direct Known Subclasses

AuditPolicy, PackagePolicy, QueueItemPolicy

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, resource) ⇒ ResourcePolicy

Returns a new instance of ResourcePolicy


6
7
8
9
# File 'app/policies/resource_policy.rb', line 6

def initialize(user, resource)
  @user = user
  @resource = resource
end

Instance Attribute Details

#resourceObject (readonly)

Returns the value of attribute resource


4
5
6
# File 'app/policies/resource_policy.rb', line 4

def resource
  @resource
end

#userObject (readonly)

Returns the value of attribute user


4
5
6
# File 'app/policies/resource_policy.rb', line 4

def user
  @user
end

Instance Method Details

#authorize!(action, message = nil) ⇒ Object

Raises:


23
24
25
# File 'app/policies/resource_policy.rb', line 23

def authorize!(action, message = nil)
  raise NotAuthorizedError, message unless public_send(action)
end

#destroy?Boolean

Returns:

  • (Boolean)

19
20
21
# File 'app/policies/resource_policy.rb', line 19

def destroy?
  false
end

#show?Boolean

Returns:

  • (Boolean)

11
12
13
# File 'app/policies/resource_policy.rb', line 11

def show?
  false
end

#update?Boolean

Returns:

  • (Boolean)

15
16
17
# File 'app/policies/resource_policy.rb', line 15

def update?
  false
end