module Truck
Constants
- Error
- VERSION
Attributes
contexts[R]
debug_mode[RW]
Public Instance Methods
boot!()
click to toggle source
# File lib/truck.rb, line 25 def boot! contexts.each_value &:boot! end
define_context(name, params = {})
click to toggle source
# File lib/truck.rb, line 15 def define_context(name, params = {}) root, parent, autoload_paths = extract_args!( params, :root, parent: nil, autoload_paths: ['.'], ) contexts[name] = Context.new(name, root, parent, autoload_paths) end
reset!()
click to toggle source
# File lib/truck.rb, line 29 def reset! shutdown! boot! end
Also aliased as: reload!
shutdown!()
click to toggle source
# File lib/truck.rb, line 35 def shutdown! each_booted_context.to_a.reverse.each &:shutdown! end
Private Instance Methods
each_booted_context(&block)
click to toggle source
# File lib/truck.rb, line 43 def each_booted_context(&block) return to_enum(:each_booted_context) unless block_given? contexts.each_value.select(&:booted?).each(&block) end
extract_args!(hsh, *mandatory)
click to toggle source
# File lib/truck.rb, line 48 def extract_args!(hsh, *mandatory) optional = mandatory.pop if mandatory.last.is_a? Hash args = mandatory.map do |key| hsh.fetch key do raise ArgumentError, "missing keyword: #{key}" end end optional.each do |key, default| args.<< hsh.fetch key, default end args end