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.



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

def detected
  @detected
end

.providersObject

Returns the value of attribute providers.



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

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.



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

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



25
26
27
# File 'lib/sym/app/password/providers.rb', line 25

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

.provider_listObject



29
30
31
# File 'lib/sym/app/password/providers.rb', line 29

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

.register(provider_class) ⇒ Object



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

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