README.md in surrounded-0.9.7 vs README.md in surrounded-0.9.8
- old
+ new
@@ -72,11 +72,11 @@
This will allow you to prepare your accessing code to use keywords.
If you need to override the initializer with additional work, you have the ability to use a block to be evaluated in the context of the initialized object.
```ruby
-initialize :role1, :role3 do
+initialize :role1, :role2 do
map_role(:role3, 'SomeRoleConstantName', initialize_the_object_to_play)
end
```
This block will be called _after_ the default initialization is done.
@@ -666,18 +666,27 @@
# or handle it yourself
def initialize(activator, account)
# this must be done to handle the mapping of roles to objects
# pass an array of arrays with role name symbol and the object for that role
map_roles([[:activator, activator],[:account, account]])
+ # or pass a hash
+ map_roles(:activator => activator, :account => account)
# or load extra objects, perform other functions, etc. if you need and then use super
account.perform_some_funtion
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
+ # If you need to mix default initialzation and extra work use a block
+ initialize :activator, :account do
+ map_roles(:third_party => get_some_other_object)
+ end
+ # but remember to set the extra accessors:
+ private_attr_reader :third_party
+
# initialize with keyword arguments
keyword_initialize(:activator, :account)
# this makes the following instance method signature with required keyword arguments
def initialize(activator:, account:)
# ...