Sha256: 11ef3ec7f2b95b880d04137fb28d38e6b8d37f5ced81e45970ea6bc804c1064b

Contents?: true

Size: 746 Bytes

Versions: 1

Compression:

Stored size: 746 Bytes

Contents

require_relative "truck/version"
require_relative "truck/string_inflections"
require_relative "truck/autoloader"
require_relative "truck/context"
require_relative "truck/const_resolver"

module Truck
  extend self

  attr :contexts
  @contexts = {}

  def define_context(name, **params)
    contexts[name] = Context.new(name, **params)
  end

  def boot!
    contexts.each_value(&:boot!)
  end

  def reset!
    each_booted_context &:reset!
  end
  alias_method :reload!, :reset!

  def shutdown!
    each_booted_context &:shutdown!
  end

  Error = Class.new StandardError

  private

  def each_booted_context(&block)
    return to_enum(:each_booted_context) unless block_given?
    contexts.each_value.select(&:booted?).each(&block)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
truck-0.8.0 lib/truck.rb