Class: ROM::Factory::AttributeRegistry Private

Inherits:
Object
  • Object
show all
Includes:
Enumerable, TSort
Defined in:
lib/rom/factory/attribute_registry.rb

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 Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(elements = []) ⇒ AttributeRegistry

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 a new instance of AttributeRegistry.



16
17
18
# File 'lib/rom/factory/attribute_registry.rb', line 16

def initialize(elements = [])
  @elements = elements
end

Instance Attribute Details

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



13
14
15
# File 'lib/rom/factory/attribute_registry.rb', line 13

def elements
  @elements
end

Instance Method Details

#<<(element) ⇒ Object

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.



31
32
33
34
35
36
# File 'lib/rom/factory/attribute_registry.rb', line 31

def <<(element)
  existing = self[element.name]
  elements.delete(existing) if existing
  elements << element
  self
end

#[](name) ⇒ Object

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.



26
27
28
# File 'lib/rom/factory/attribute_registry.rb', line 26

def [](name)
  detect { |e| e.name.equal?(name) }
end

#associationsObject

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.



49
50
51
# File 'lib/rom/factory/attribute_registry.rb', line 49

def associations
  self.class.new(elements.select { |e| e.is_a?(Attributes::Association::Core) })
end

#dupObject

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.



39
40
41
# File 'lib/rom/factory/attribute_registry.rb', line 39

def dup
  self.class.new(elements.dup)
end

#each(&block) ⇒ Object

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.



21
22
23
# File 'lib/rom/factory/attribute_registry.rb', line 21

def each(&block)
  elements.each(&block)
end

#reject(&block) ⇒ Object

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.



53
54
55
# File 'lib/rom/factory/attribute_registry.rb', line 53

def reject(&block)
  self.class.new(elements.reject(&block))
end

#valuesObject

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.



44
45
46
# File 'lib/rom/factory/attribute_registry.rb', line 44

def values
  self.class.new(elements.select(&:value?))
end