Module: Sym::App::Password::Providers

Defined in:
lib/sym/app/password/providers.rb,
lib/sym/app/password/providers/memcached_provider.rb

Defined Under Namespace

Classes: MemcachedProvider

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.detectedObject

Returns the value of attribute detected.



7
8
9
# File 'lib/sym/app/password/providers.rb', line 7

def detected
  @detected
end

.providersObject

Returns the value of attribute providers.



7
8
9
# File 'lib/sym/app/password/providers.rb', line 7

def providers
  @providers
end

.registryObject

Returns the value of attribute registry.



7
8
9
# File 'lib/sym/app/password/providers.rb', line 7

def registry
  @registry
end

Class Method Details

.detectObject

Detect first instance tht is “alive?” and return it.



17
18
19
20
21
# File 'lib/sym/app/password/providers.rb', line 17

def detect
  self.detected ||= self.providers.inject(nil) do |instance, provider_class|
    instance || (p = provider_class.new; p.alive? ? p : nil)
  end
end

.provider(p = nil, **opts, &block) ⇒ Object



23
24
25
# File 'lib/sym/app/password/providers.rb', line 23

def provider(p = nil, **opts, &block)
  provider_from_argument(p, **opts, &block) || detect
end

.provider_listObject



27
28
29
# File 'lib/sym/app/password/providers.rb', line 27

def provider_list
  registry.keys.map(&:to_s).join(', ')
end

.register(provider_class) ⇒ Object



9
10
11
12
13
14
# File 'lib/sym/app/password/providers.rb', line 9

def register(provider_class)
  self.registry                        ||= {}
  registry[short_name(provider_class)] = provider_class
  self.providers                       ||= []
  self.providers << provider_class
end