Skip to content
Simple DIY dependency injection for JRuby that can use Spring as well
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Simple DIY dependency injection framework for Ruby that

  • allows you to register any Ruby object with an application context and then refer to it by name
  • can integrate a Java Spring Context as well. This is particularly useful if you have mixed Java and Jruby code and want to expose your Spring beans to a JRuby application.
  • integrates a solution for setting and reading feature flags


Simply copy app_context into your project. There is no gem currently and the version I have here is a simplified version of what I use in my applications. The code is simple enough that you may want to tweak it anyway.

Create an application definition module where you wire up all your Ruby objects:

require 'app_context'

module ApplicationDefinition  
  # make sure we only do this once
  if !@@initialized
    @@ctx.register(:myname, someobject)

Then whenever you need to inject a dependency, simply refer to it like this:


if AppContext.instance.flags[:myflag] 
    # do stuff


This code is licensed under the expat license. See the LICENSE file for details.

You can’t perform that action at this time.