Class: Entitlements::Extras::Base

Inherits:
Object
  • Object
show all
Includes:
Contracts::Core
Defined in:
lib/entitlements/extras/base.rb

Direct Known Subclasses

LDAPGroup::Base, Orgchart::Base

Constant Summary collapse

C =
::Contracts

Class Method Summary collapse

Methods included from Contracts::Core

common, extended, included

Class Method Details

.configObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/entitlements/extras/base.rb', line 19

def self.config
  @extra_config ||= begin
    # classname is something like "Entitlements::Extras::MyExtraClassName::Base" - want to pull
    # out the "MyExtraClassName" from this string.
    classname = self.to_s.split("::")[-2]
    decamelized_class = Entitlements::Util::Util.decamelize(classname)
    cfg = Entitlements.config.fetch("extras", {}).fetch(decamelized_class, nil)
    cfg.is_a?(Hash) ? cfg : {}
  end
end

.reset!Object

This is intended for unit tests to reset class variables.

Takes no arguments.

Returns nothing.



35
36
37
# File 'lib/entitlements/extras/base.rb', line 35

def self.reset!
  @extra_config = nil
end