Class: SmartCore::Initializer::Extensions::List Private
- Inherits:
-
Object
- Object
- SmartCore::Initializer::Extensions::List
- Includes:
- Enumerable
- Defined in:
- lib/smart_core/initializer/extensions/list.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #add(extension) ⇒ void (also: #<<) private
- #concat(list) ⇒ void private
- #each(&block) ⇒ Enumerable private
- #initialize ⇒ void constructor private
- #size ⇒ Integer private
Constructor Details
#initialize ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 18 19 20 21 |
# File 'lib/smart_core/initializer/extensions/list.rb', line 15 def initialize @extensions = [] # NOTE: frozen snapshot rebuilt on mutation so the instantiation path can # iterate (and skip when empty) lock-free. @snapshot = [].freeze @lock = SmartCore::Engine::ReadWriteLock.new end |
Instance Method Details
#add(extension) ⇒ void Also known as: <<
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
29 30 31 32 33 34 |
# File 'lib/smart_core/initializer/extensions/list.rb', line 29 def add(extension) @lock.write_sync do extensions << extension @snapshot = extensions.dup.freeze end end |
#concat(list) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
43 44 45 46 47 |
# File 'lib/smart_core/initializer/extensions/list.rb', line 43 def concat(list) @lock.write_sync do list.each { |extension| add(extension.dup) } end end |
#each(&block) ⇒ Enumerable
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Lock-free: iterates the immutable snapshot maintained on mutation.
57 58 59 |
# File 'lib/smart_core/initializer/extensions/list.rb', line 57 def each(&block) block_given? ? @snapshot.each(&block) : @snapshot.each end |
#size ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Lock-free: reads the size of the immutable snapshot.
68 69 70 |
# File 'lib/smart_core/initializer/extensions/list.rb', line 68 def size @snapshot.size end |