Skip to Content Skip to Search

class Rails::Initializable::Collection

Inherits From

Public class methods

Source code GitHub
# File railties/lib/rails/initializable.rb, line 44
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

Public instance methods

Source code GitHub
# File railties/lib/rails/initializable.rb, line 70
def +(other)
  dup.concat(other.to_a)
end
Source code GitHub
# File railties/lib/rails/initializable.rb, line 74
def <<(initializer)
  @collection << initializer
  @order[initializer.before] << initializer.name if initializer.before
  @order[initializer.name] << initializer.after if initializer.after
  @resolve[initializer.name] << initializer
  self
end

Alias for: push.

Source code GitHub
# File railties/lib/rails/initializable.rb, line 89
def concat(*initializer_collections)
  initializer_collections.each do |initializers|
    initializers.each(&method(:<<))
  end
  self
end

Also aliased as: tsort_each_node.

Source code GitHub
# File railties/lib/rails/initializable.rb, line 59
def each(&block)
  @collection.each(&block)
end
Source code GitHub
# File railties/lib/rails/initializable.rb, line 96
def has?(name)
  @resolve.key?(name)
end
Source code GitHub
# File railties/lib/rails/initializable.rb, line 55
def last
  @collection.last
end

Also aliased as: append.

Source code GitHub
# File railties/lib/rails/initializable.rb, line 82
def push(*initializers)
  initializers.each(&method(:<<))
  self
end
Source code GitHub
# File railties/lib/rails/initializable.rb, line 51
def to_a
  @collection
end
Source code GitHub
# File railties/lib/rails/initializable.rb, line 64
def tsort_each_child(initializer, &block)
  @order[initializer.name].each do |name|
    @resolve[name].each(&block)
  end
end

Alias for: each.

Definition files