IoC

Installation

gem 'ruby-ioc'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install ruby-ioc

Usage


IoC::Container.init do |container|
  # singleton value
  container.register(:user_repository, UserRepository)

  # new instance value
  container.register(:checkout_service) { CheckoutService.new }
end

class  CheckoutService
  inject :user_repository

  def  call(checkout)
    # valid checkout
    # ...
    # ...
    checkout_repository.save(checkout)
  end
end

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/alissonbrunosa/ruby-ioc.

License

The gem is available as open source under the terms of the MIT License.