Class: Rails::Initializable::Collection
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
TSort,
::Enumerable ,
::ActiveSupport::EnumerableCoreExt::Constants
|
|
Inherits: | Object |
Defined in: | railties/lib/rails/initializable.rb |
Class Method Summary
- .new(initializers = nil) ⇒ Collection constructor
Instance Attribute Summary
::Enumerable
- Included
#many? | Returns |
Instance Method Summary
- #+(other)
- #<<(initializer)
- #concat(initializers)
- #each(&block) (also: #tsort_each_node)
- #has?(name) ⇒ Boolean
- #last
- #to_a
- #tsort_each_child(initializer, &block)
-
#tsort_each_node(&block)
Alias for #each.
::Enumerable
- Included
#compact_blank | Returns a new |
#exclude? | The negative of the |
#excluding | Returns a copy of the enumerable excluding the specified elements. |
#in_order_of | Returns a new |
#including | Returns a new array that includes the passed elements. |
#index_by | Convert an enumerable to a hash, using the block result as the key and the element as the value. |
#index_with | Convert an enumerable to a hash, using the element as the key and the block result as the value. |
#maximum | Calculates the maximum from the extracted elements. |
#minimum | Calculates the minimum from the extracted elements. |
#pick | Extract the given key from the first element in the enumerable. |
#pluck | Extract the given key from each element in the enumerable. |
#sole | Returns the sole item in the enumerable. |
#without | Alias for Enumerable#excluding. |
#as_json |
::ActiveSupport::EnumerableCoreExt::Constants
- Included
Constructor Details
.new(initializers = nil) ⇒ Collection
# File 'railties/lib/rails/initializable.rb', line 41
def initialize(initializers = nil) @order = Hash.new { |hash, key| hash[key] = Set.new } @resolve = Hash.new { |hash, key| hash[key] = Set.new } @collection = [] concat(initializers) if initializers end
Instance Method Details
#+(other)
[ GitHub ]#<<(initializer)
[ GitHub ]# File 'railties/lib/rails/initializable.rb', line 71
def <<(initializer) @collection << initializer @order[initializer.before] << initializer.name if initializer.before @order[initializer.name] << initializer.after if initializer.after @resolve[initializer.name] << initializer end
#concat(initializers)
[ GitHub ]# File 'railties/lib/rails/initializable.rb', line 78
def concat(initializers) initializers.each(&method(:<<)) self end
#each(&block) Also known as: #tsort_each_node
[ GitHub ]# File 'railties/lib/rails/initializable.rb', line 56
def each(&block) @collection.each(&block) end
#has?(name) ⇒ Boolean
# File 'railties/lib/rails/initializable.rb', line 83
def has?(name) @resolve.key?(name) end
#last
[ GitHub ]# File 'railties/lib/rails/initializable.rb', line 52
def last @collection.last end
#to_a
[ GitHub ]# File 'railties/lib/rails/initializable.rb', line 48
def to_a @collection end
#tsort_each_child(initializer, &block)
[ GitHub ]#tsort_each_node(&block)
Alias for #each.
# File 'railties/lib/rails/initializable.rb', line 60
alias :tsort_each_node :each