Sha256: 077d5d418e1b169bd800ba0ca8fdf197f900e0c67078585535bdeaafc50dcb9c
Contents?: true
Size: 848 Bytes
Versions: 1
Compression:
Stored size: 848 Bytes
Contents
require 'habu/setup' require_relative 'user' require_relative 'new_user_service' # Create a new container container = Habu::Container.new # Register user_repository service by passing the block as service factory container[:user_repository] { User } # Call Habu::Container#new to get instance new_user = container.new(NewUserService).call("hanachin") # => #<struct User name="hanachin"> # Factory block take a container as argument container[:new_user] do |c| # You can get the service object by calling Container#[](service_name) NewUserService.new(c[:user_repository]) end new_user = container[:new_user].call("hanachin") # => #<struct User name="hanachin"> # Using container as refinements for shorthand for container.new using container.to_refinements new_user = NewUserService.new.call("hanachin") # => #<struct User name="hanachin">
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
habu-0.1.1 | example/app.rb |