README.md in snfoil-context-1.0.0 vs README.md in snfoil-context-1.0.1
- old
+ new
@@ -48,11 +48,11 @@
### Initialize
When you `new` up a SnFoil Context you should provide the entity running the actions. This will usually be a user but you can pass in anything. This will be accessible from within the context as `entity`.
```ruby
- TokenContext.new(current_user)
+ TokenContext.new(entity: current_user)
```
### Actions
Actions are a group of hookable intervals that create a workflow around a single primary function.
@@ -90,11 +90,11 @@
include SnFoil::Context
action(:expire) { |options| options[:object].update(expired_at: Time.current) }
end
-TokenContext.new(current_user).expire(object: current_token)
+TokenContext.new(entity: current_user).expire(object: current_token)
```
If you want to reuse the primary action or just prefer methods, you can pass in the method name you would like to call, rather than providing a block. If a method name and a block are provided, the block is ignored.
@@ -333,10 +333,10 @@
```
Just like for an action SnFoil allows you to define both hooks and a method. To run this interval you call it using the `run_interval` method.
```ruby
-TokenContext.new(entity).run_interval(:demo, **options)
+TokenContext.new(entity: entity).run_interval(:demo, **options)
```
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.