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
-
.detected ⇒ Object
Returns the value of attribute detected.
-
.providers ⇒ Object
Returns the value of attribute providers.
-
.registry ⇒ Object
Returns the value of attribute registry.
Class Method Summary collapse
-
.detect ⇒ Object
Detect first instance tht is “alive?” and return it.
- .provider(p = nil, **opts, &block) ⇒ Object
- .provider_list ⇒ Object
- .register(provider_class) ⇒ Object
Class Attribute Details
.detected ⇒ Object
Returns the value of attribute detected.
7 8 9 |
# File 'lib/sym/app/password/providers.rb', line 7 def detected @detected end |
.providers ⇒ Object
Returns the value of attribute providers.
7 8 9 |
# File 'lib/sym/app/password/providers.rb', line 7 def providers @providers end |
.registry ⇒ Object
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
.detect ⇒ Object
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_list ⇒ Object
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 |