Class: Micro::Authorization::Policy

Inherits:
Object
  • Object
show all
Defined in:
lib/micro/authorization/policy.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, subject = nil, permissions: nil) ⇒ Policy

Returns a new instance of Policy.



12
13
14
15
16
# File 'lib/micro/authorization/policy.rb', line 12

def initialize(context, subject = nil, permissions: nil)
  @context = context
  @subject = subject
  @permissions = permissions
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, **keyargs, &block) ⇒ Object



18
19
20
21
# File 'lib/micro/authorization/policy.rb', line 18

def method_missing(method, *args, **keyargs, &block)
  return false if method =~ /\?\z/
  super(method)
end

Class Method Details

.type(klass) ⇒ Object

Raises:

  • (ArgumentError)


6
7
8
9
10
# File 'lib/micro/authorization/policy.rb', line 6

def self.type(klass)
  return klass if klass < self

  raise ArgumentError, "policy must be a #{self.name}"
end