Morphine - Lightweight dependency injection for Ruby

GitHubber Brandon Keepers:

Many argue that you don’t need dependency injection in dynamic languages like Ruby. What they are really saying is you don’t need a complicated dependency injection framework, and they’re right.

So Brandon created Morphine, a simple DI library for Ruby. With Morphine, you can create a DI container by including the Morphine module and specifying your dependencies.

class Application
  include Morphine

  register :track_service do, config.tracking_queue)

  register :track_processor do, config.tracking_queue)


  register :kestrel_client do
    c = config['kestrel'].dup'servers'), c.symbolize_keys)

  register :blocking_kestrel_client do

If you feel Ruby benefits from dependency injection and want to contribute, check out the just released source on GitHub.

News Films

Our little film studio focuses on telling developer-centric stories that need to be seen.

GopherCon 2016 Conference Recap

0:00 / 0:00