Class: SmartCore::Initializer::AttributeSet Private

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/smart_core/initializer/attribute_set.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.

Since:

  • 0.5.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializevoid

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.

Since:

  • 0.5.0



19
20
21
22
# File 'lib/smart_core/initializer/attribute_set.rb', line 19

def initialize
  @attributes = {}
  @access_lock = Mutex.new
end

Instance Attribute Details

#attributesHash<Symbol, SmartCore::Initializer::Attribute> (readonly)

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.

Returns:

Since:

  • 0.5.0



13
14
15
# File 'lib/smart_core/initializer/attribute_set.rb', line 13

def attributes
  @attributes
end

Instance Method Details

#add_attribute(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.

Parameters:

Since:

  • 0.5.0



29
30
31
# File 'lib/smart_core/initializer/attribute_set.rb', line 29

def add_attribute(attribute)
  thread_safe { attributes[attribute.name] = attribute }
end

#concat(attribute_set) ⇒ 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.

Parameters:

Since:

  • 0.5.0



39
40
41
# File 'lib/smart_core/initializer/attribute_set.rb', line 39

def concat(attribute_set)
  thread_safe { attributes.merge!(attribute_set.dup.attributes) }
end

#conflicts_with?(attribute) ⇒ Boolean

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.

Parameters:

Returns:

  • (Boolean)

Since:

  • 0.5.0



48
49
50
# File 'lib/smart_core/initializer/attribute_set.rb', line 48

def conflicts_with?(attribute)
  thread_safe { attributes.key?(attribute.name) }
end

#dupSmartCore::Initializer::AttributeSet

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.

Returns:

Since:

  • 0.5.0



56
57
58
59
60
61
62
63
64
# File 'lib/smart_core/initializer/attribute_set.rb', line 56

def dup
  thread_safe do
    self.class.new.tap do |duplicate|
      attributes.each_value do |attribute|
        duplicate.add_attribute(attribute.dup)
      end
    end
  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.

Returns:

  • (Enumerable)

Since:

  • 0.5.0



78
79
80
# File 'lib/smart_core/initializer/attribute_set.rb', line 78

def each(&block)
  thread_safe { block_given? ? attributes.each_value(&block) : attributes.each_value }
end

#sizeInteger

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.

Returns:

  • (Integer)

Since:

  • 0.5.0



70
71
72
# File 'lib/smart_core/initializer/attribute_set.rb', line 70

def size
  thread_safe { attributes.size }
end