Class: PermissionSettings::Verify

Inherits:
Object
  • Object
show all
Defined in:
lib/permission_settings/verify.rb

Direct Known Subclasses

VerifyInstance

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(permission_keys, role, resource, &block) ⇒ Verify

Returns a new instance of Verify.



8
9
10
11
12
13
14
# File 'lib/permission_settings/verify.rb', line 8

def initialize(permission_keys, role, resource, &block)
  @permission_keys = permission_keys.map(&:to_s)
  @role = role
  @resource = resource
  @block = block
  @scope = PermissionSettings.configuration.scope_name(resource.class)
end

Class Method Details

.call(permission_keys = [], role: nil, resource: nil, &block) ⇒ Object



16
17
18
# File 'lib/permission_settings/verify.rb', line 16

def self.call(permission_keys = [], role: nil, resource: nil, &block)
  new(permission_keys, role, resource, &block).call
end

Instance Method Details

#callObject



20
21
22
23
# File 'lib/permission_settings/verify.rb', line 20

def call
  extract_permission_value
  raise_not_found_error if permission_value.nil?
end