Class: SmartCore::Initializer::Attribute::List Private
- Inherits:
-
Object
- Object
- SmartCore::Initializer::Attribute::List
- Includes:
- Enumerable
- Defined in:
- lib/smart_core/initializer/attribute/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(attribute) ⇒ void (also: #<<) private
- #concat(list) ⇒ void private
- #count(&block) ⇒ Integer private
- #each(&block) ⇒ Enumerable private
- #fetch(attribute_name) ⇒ SmartCore::Initializer::Atribute (also: #[]) private
- #include?(attribute) ⇒ void 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 |
# File 'lib/smart_core/initializer/attribute/list.rb', line 15 def initialize @attributes = {} @lock = SmartCore::Engine::ReadWriteLock.new end |
Instance Method Details
#add(attribute) ⇒ 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.
47 48 49 |
# File 'lib/smart_core/initializer/attribute/list.rb', line 47 def add(attribute) @lock.write_sync { attributes[attribute.name] = attribute } 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.
58 59 60 61 62 |
# File 'lib/smart_core/initializer/attribute/list.rb', line 58 def concat(list) @lock.write_sync do list.each { |attribute| add(attribute.dup) } end end |
#count(&block) ⇒ 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.
100 101 102 |
# File 'lib/smart_core/initializer/attribute/list.rb', line 100 def count(&block) @lock.read_sync { attributes.values.count(&block) } 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.
79 80 81 82 83 |
# File 'lib/smart_core/initializer/attribute/list.rb', line 79 def each(&block) @lock.read_sync do block_given? ? attributes.values.each(&block) : attributes.values.each end end |
#fetch(attribute_name) ⇒ SmartCore::Initializer::Atribute 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.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/smart_core/initializer/attribute/list.rb', line 28 def fetch(attribute_name) @lock.read_sync do raise( ::SmartCore::Initializer::UndefinedAttributeError, "Attribute with `#{attribute_name}` name is not defined in your constructor. " \ "Please, check your attribute definitions inside your class." ) unless attributes.key?(attribute_name) attributes[attribute_name] end end |
#include?(attribute) ⇒ 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.
69 70 71 |
# File 'lib/smart_core/initializer/attribute/list.rb', line 69 def include?(attribute) @lock.read_sync { attributes.key?(attribute.name) } 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.
90 91 92 |
# File 'lib/smart_core/initializer/attribute/list.rb', line 90 def size @lock.read_sync { attributes.size } end |