README.md in surrounded-0.9.1 vs README.md in surrounded-0.9.2
- old
+ new
@@ -4,14 +4,12 @@
[![Build Status](https://travis-ci.org/saturnflyer/surrounded.png?branch=master)](https://travis-ci.org/saturnflyer/surrounded)
[![Code Climate](https://codeclimate.com/github/saturnflyer/surrounded.png)](https://codeclimate.com/github/saturnflyer/surrounded)
[![Coverage Status](https://coveralls.io/repos/saturnflyer/surrounded/badge.png)](https://coveralls.io/r/saturnflyer/surrounded)
[![Gem Version](https://badge.fury.io/rb/surrounded.png)](http://badge.fury.io/rb/surrounded)
-# Get work done with only what you need and nothing more.
+Surrounded is designed to help you better manage your business logic by keeping cohesive behaviors together. Bring objects together to implement your use cases and gain behavior only when necessary.
-Surrounded is designed to help you better manage your business logic.
-
## How to think about your objects
First, name the problem you're solving. Then, break down your problem into responsible roles.
Use your problem name as a class and extend it with `Surrounded::Context`
@@ -541,14 +539,16 @@
self
end
end
```
-The `:interface` option is a special object which has all of its methods removed (excepting `__send__` and `object_id`) so that other methods will be pulled from the ones that you define, or from the object it attempts to proxy.
+The `:interface` option is a special object which has all of the standard Object methods removed (excepting `__send__` and `object_id`) so that other methods will be pulled from the ones that you define, or from the object it attempts to proxy.
Notice that the `:interface` allows you to return `self` whereas the `:wrap` acts more like a wrapper and forces you to deal with that shortcoming by using it's wrapped-object-accessor method: `__getobj__`.
+The downside of using an interface is that it is still a wrapper. All of your defined role methods are executed in the context of the object playing the role, but the interface has it's own identity.
+
If you'd like to choose one and use it all the time, you can set the default:
```ruby
class MoneyTransfer
extend Surrounded::Context
@@ -634,10 +634,17 @@
super
end
# these also must be done if you create your own initialize method.
# this is a shortcut for using attr_reader and private
private_attr_reader :activator, :account
+
+ # initialize with keyword arguments
+ keyword_initialize(:activator, :account)
+ # this makes the following instance method signature with required keyword arguments
+ def initialize(activator:, account:)
+ # ...
+ end
role :activator do # module by default
def some_behavior; end
end
@@ -722,10 +729,10 @@
end
```
## Dependencies
-The dependencies are minimal. The plan is to keep it that way but allow you to configure things as you need. The [Triad](http://github.com/saturnflyer/triad) project was written specifically to manage the mapping of roles and objects to the modules which contain the behaviors.
+The dependencies are minimal. The plan is to keep it that way but allow you to configure things as you need. The [Triad](http://github.com/saturnflyer/triad) project was written specifically to manage the mapping of roles and objects to the modules which contain the behaviors. It is used in Surrounded to keep track of role player, roles, and role constant names but it is not a hard requirement. You may implement your own but presently you'll need to dive into the implementation to fully understand how. Future updates may provide better support and guidance.
If you're using [Casting](http://github.com/saturnflyer/casting), for example, Surrounded will attempt to use that before extending an object, but it will still work without it.
## Support for other ways to apply behavior