README.md in faker_maker-0.7.0 vs README.md in faker_maker-0.7.1

- old
+ new

@@ -121,32 +121,10 @@ Faker::Commerce.product_name end end ``` -JSON keys are often have a different stylistic convention than Ruby's snake-case so you can override the attribute's name when is come to generating JSON: - -```ruby -FakerMaker.factory :item do - name( json: 'productName' ) { Faker::Commerce.product_name } - price( json: 'ticketPrice' ) { Faker::Commerce.price } -end -``` - -so in Ruby you would access the attribute using the attribute name as in: - -```ruby -item = FM[:item].build -puts item -``` - -but `item.to_json` would produce: - -```javascript -{"productName":"Enormous Silk Pants","ticketPrice":55.35} -``` - ### 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: @@ -154,9 +132,17 @@ ```ruby result = FakerMaker[:basket].build ``` will generate a new instance using the Basket factory. Because an actual class is defined, you can instantiate an object directly through `Basket.new` but that will not populate any of the attributes. + +It's possible to override attributes at build-time: + +```ruby +result = FakerMaker[:item].build{ |i| i.name = 'Electric Sheep' } +``` + +Calling `result.to_json` will give a stringified JSON representation. Because ActiveSupport is used under the covers, `as_json` will give you a `Hash` rather than the stringified version. As a convenience, you can request a JSON representation directly: ```ruby result = FakerMaker[:basket].to_json