README.md in nurse-rb-2.0.0 vs README.md in nurse-rb-2.1.0
- old
+ new
@@ -3,11 +3,11 @@
Nurse, for your dependency injection
Code quality
[![Build Status](https://travis-ci.org/mjacobus/nurse-rb.svg)](https://travis-ci.org/mjacobus/nurse-rb)
-[![Coverage Status](https://coveralls.io/repos/github/mjacobus/nurse/badge.svg?branch=master)](https://coveralls.io/github/mjacobus/nurse?branch=master)
+[![Coverage Status](https://coveralls.io/repos/github/mjacobus/nurse-rb/badge.svg?branch=master)](https://coveralls.io/github/mjacobus/nurse-rb?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/mjacobus/nurse-rb/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/mjacobus/nurse-rb/?branch=master)
[![Code Climate](https://codeclimate.com/github/mjacobus/nurse-rb/badges/gpa.svg)](https://codeclimate.com/github/mjacobus/nurse-rb)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mjacobus/nurse-rb/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/mjacobus/nurse-rb/?branch=master)
Package information
@@ -18,20 +18,20 @@
## Installation
Add this line to your application's Gemfile:
```ruby
-gem 'nurse'
+gem 'nurse-rb'
```
And then execute:
$ bundle
Or install it yourself as:
- $ gem install nurse
+ $ gem install nurse-rb
## Usage
### Defining dependencies
@@ -40,11 +40,11 @@
dependency_manager.share(:connection) do |dependency_manager|
MyConnection.new("mysql://root@localhost/my_db")
end
-dependency_manager.share(UserRepository) do |dependency_manager|
+dependency_manager.share(:user_repository) do |dependency_manager|
connection = dependency_manager.get(:connection)
UserRepository.new(connection)
end
```
@@ -63,40 +63,37 @@
end
private
def repository
- dependency_manager.get(UserRepository)
+ dependency_manager.get(:user_repository)
end
end
```
+### Using factories
+
```ruby
-class DatabaseConnectionFactory < Nurse::SharedServiceFactory
+class DatabaseConnectionFactory < Nurse::ServiceFactory
+ share true
+ key :db_connection
+
def create_service(dependencies)
DatabaseConnection.new(dependencies.get(:db_config))
end
-
- def dependency_key
- :db_connection
- end
end
class UserRepositoryFactory < Nurse::ServiceFactory
+ key :user_repository
+
def create_service(dependencies)
UserRepository.new(dependencies.get(:db_connection))
end
-
- def dependency_key
- :user_repository
- end
end
dependency_manager.add_factory(DatabaseConnectionFactory.new)
dependency_manager.add_factory(UserRepositoryFactory.new)
```
-
-### Using factories
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.