README.md in faker_maker-1.0.1 vs README.md in faker_maker-1.1.0
- old
+ new
@@ -57,10 +57,22 @@
FakerMaker.factory :response do
body { { title: 'First Post', content: 'This is part of a hash' } }
end
```
+Blocks are executed in the context of their instance. This means you can refer to variables already defined:
+
+```ruby
+FakerMaker.factory :user, class: 'EmailUser' do
+ title {'Ms'}
+ name {'Patsy Stone'}
+ formal_name {"#{title} #{name}"}
+ email {'patsy@fabulous.co.uk'}
+ admin {false}
+end
+```
+
### Inheritance
FakerMaker can exploit the Ruby class hierarchy to provide additional specialisation or to override some behaviours:
```ruby
@@ -126,10 +138,12 @@
Faker::Commerce.product_name
end
end
```
+### JSON field names
+
### Building instances
Instances are Plain Ol' Ruby Objects and the attributes are attached with getters and setters with their values assigned to the value return from their block at build time.
To build an object:
@@ -170,10 +184,10 @@
```ruby
result = FakerMaker[:basket].to_json
```
-As another convenience, `FakerMaker` is also assign to the variable `FM` to it is possible to write just:
+As another convenience, `FakerMaker` is also assigned to the variable `FM` to it is possible to write just:
```ruby
result = FM[:basket].build
```