Sha256: 313c3006f50f1e6ba51750908e4c643dc9eb87c85402af004fcb5cea67ed5863
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
# frozen_string_literal: true # @api private # @since 0.1.0 class SmartCore::Initializer::Attribute::List # @since 0.1.0 include Enumerable # @return [void] # # @api private # @since 0.1.0 def initialize @attributes = {} @lock = SmartCore::Engine::Lock.new end # @param attribute [SmartCore::Initializer::Attribute] # @return [void] # # @api private # @since 0.1.0 def add(attribute) thread_safe { attributes[attribute.name] = attribute } end alias_method :<<, :add # @param attribute [SmartCore::Initializer::Attribute] # @return [void] # # @api private # @since 0.1.0 def include?(attribute) thread_safe { attributes.key?(attribute.name) } end # @param block [Block] # @return [Enumerable] # # @api private # @since 0.1.0 def each(&block) thread_safe do block_given? ? attributes.values.each(&block) : attributes.values.each end end private # @return [Hash<String,SmartCore::Initializer::Attribute>] # # @api private # @since 0.1.0 attr_reader :attributes # @param block [Block] # @return [Any] # # @api private # @since 0.1.0 def thread_safe(&block) @lock.synchronize(&block) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
smart_initializer-0.0.0 | lib/smart_core/initializer/attribute/list.rb |