README.md in surrounded-0.8.2 vs README.md in surrounded-0.8.3
- old
+ new
@@ -338,11 +338,11 @@
Using the `role` method to define modules and classes takes care of the setup for you. This way you can swap between implementations:
```ruby
- # this uses modules
+ # this uses modules which include Surrounded
role :source do
def transfer
self.balance -= amount
destination.balance += amount
self
@@ -404,9 +404,33 @@
self.balance -= amount
destination.balance += amount
self
end
end
+end
+```
+
+## Working with collections
+
+If you want to use an Array of objects (for example) as a role player in your context,
+you may do so. If you want each item in your collection to gain behavior, you merely need to
+create a role for the items.
+
+Surrounded will attempt to guess at the singular role name. For example, a role player named `members` would
+be given the behaviors from a `Members` behavior module or class. Each item in your `members` collection
+would be given behavior from a `Member` behavior module or class if you create one.
+
+```ruby
+class Organization
+ initialize :leader, :members
+
+ role :members do
+ # special behavior for the collection
+ end
+
+ role :member do
+ # special behavior to be applied to each member in the collection
+ end
end
```
## Policies for the application of role methods