Module: Apiphobic::Authorization::Resource::ClassMethods

Defined in:
lib/apiphobic/authorization/resource.rb

Instance Method Summary collapse

Instance Method Details

#authorized_resource_classObject



23
24
25
# File 'lib/apiphobic/authorization/resource.rb', line 23

def authorized_resource_class
  Object.const_get(authorized_resource_class_name)
end

#authorized_resource_class_nameObject



51
52
53
# File 'lib/apiphobic/authorization/resource.rb', line 51

def authorized_resource_class_name
  singular_resource_class_name
end

#authorized_scope_root_classObject



31
32
33
# File 'lib/apiphobic/authorization/resource.rb', line 31

def authorized_scope_root_class
  @authorized_scope_root_class ||= Object.const_get(singular_resource_class_name)
end

#authorizer_classObject



14
15
16
# File 'lib/apiphobic/authorization/resource.rb', line 14

def authorizer_class
  @authorizer_class ||= Object.const_get(authorizer_class_name)
end

#authorizer_class_components(type = nil) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/apiphobic/authorization/resource.rb', line 35

def authorizer_class_components(type = nil)
  [
    name_components['root_module'],
    'Authorizers',
    name_components['submodules'],
    base_resource_name,
    type,
  ]
    .map(&:to_s)
    .reject(&:empty?)
end

#authorizer_class_name(type = nil) ⇒ Object



47
48
49
# File 'lib/apiphobic/authorization/resource.rb', line 47

def authorizer_class_name(type = nil)
  authorizer_class_components(type).join('::')
end

#authorizer_parameters_classObject



18
19
20
21
# File 'lib/apiphobic/authorization/resource.rb', line 18

def authorizer_parameters_class
  @authorizer_parameters_class ||= \
    Object.const_get(authorizer_class_name('Parameters'))
end

#authorizer_scope_classObject



27
28
29
# File 'lib/apiphobic/authorization/resource.rb', line 27

def authorizer_scope_class
  @authorizer_scope_class ||= Object.const_get(authorizer_class_name('Scope'))
end