alissonbrunosa / ruby-ioc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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(:checkout_repository, CheckoutRepository)
  
  # new instance value
  container.register(:checkout_service) { CheckoutService.new }
end

class  CheckoutService
  inject :checkout_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.

About

License:MIT License


Languages

Language:Ruby 97.7%Language:Shell 2.3%