Methods
Included Modules
- Enumerable
- TSort
Class Public methods
new(initializers = nil)
📝 Source code
# File railties/lib/rails/initializable.rb, line 43
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
🔎 See on GitHub
Instance Public methods
+(other)
📝 Source code
# File railties/lib/rails/initializable.rb, line 69
def +(other)
dup.concat(other.to_a)
end
🔎 See on GitHub
<<(initializer)
📝 Source code
# File railties/lib/rails/initializable.rb, line 73
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
🔎 See on GitHub
concat(*initializer_collections)
📝 Source code
# File railties/lib/rails/initializable.rb, line 88
def concat(*initializer_collections)
initializer_collections.each do |initializers|
initializers.each(&method(:<<))
end
self
end
🔎 See on GitHub
each(&block)
Also aliased as: tsort_each_node
📝 Source code
# File railties/lib/rails/initializable.rb, line 58
def each(&block)
@collection.each(&block)
end
🔎 See on GitHub
has?(name)
📝 Source code
# File railties/lib/rails/initializable.rb, line 95
def has?(name)
@resolve.key?(name)
end
🔎 See on GitHub
last()
📝 Source code
# File railties/lib/rails/initializable.rb, line 54
def last
@collection.last
end
🔎 See on GitHub
push(*initializers)
Also aliased as: append
📝 Source code
# File railties/lib/rails/initializable.rb, line 81
def push(*initializers)
initializers.each(&method(:<<))
self
end
🔎 See on GitHub
to_a()
📝 Source code
# File railties/lib/rails/initializable.rb, line 50
def to_a
@collection
end
🔎 See on GitHub
tsort_each_child(initializer, &block)
📝 Source code
# File railties/lib/rails/initializable.rb, line 63
def tsort_each_child(initializer, &block)
@order[initializer.name].each do |name|
@resolve[name].each(&block)
end
end
🔎 See on GitHub