Class: AdManagerApi::Utils::UtilityRegistry
- Inherits:
-
Object
- Object
- AdManagerApi::Utils::UtilityRegistry
- Includes:
- Singleton
- Defined in:
- lib/ad_manager_api/utils.rb
Overview
Class to keep a list of unique utilities used in order to perform tracking of client library features.
Instance Attribute Summary collapse
-
#enabled ⇒ Object
Returns the value of attribute enabled.
Instance Method Summary collapse
- #add(util) ⇒ Object
- #extract! ⇒ Object
-
#initialize ⇒ UtilityRegistry
constructor
A new instance of UtilityRegistry.
- #length ⇒ Object
Constructor Details
#initialize ⇒ UtilityRegistry
Returns a new instance of UtilityRegistry.
33 34 35 36 37 |
# File 'lib/ad_manager_api/utils.rb', line 33 def initialize @enabled = true @registry = Set.new @lock = Mutex.new end |
Instance Attribute Details
#enabled ⇒ Object
Returns the value of attribute enabled.
31 32 33 |
# File 'lib/ad_manager_api/utils.rb', line 31 def enabled @enabled end |
Instance Method Details
#add(util) ⇒ Object
51 52 53 |
# File 'lib/ad_manager_api/utils.rb', line 51 def add(util) @lock.synchronize { @registry.add(util) if @enabled } end |
#extract! ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/ad_manager_api/utils.rb', line 39 def extract! @lock.synchronize do registry = @registry.dup @registry.clear return registry end end |
#length ⇒ Object
47 48 49 |
# File 'lib/ad_manager_api/utils.rb', line 47 def length @lock.synchronize { @registry.length } end |