README.md in pbbuilder-0.12.0 vs README.md in pbbuilder-0.13.0

- old
+ new

@@ -1,9 +1,48 @@ # Pbbuilder -Short description and motivation. +PBBuilder generates [Protobuf](https://developers.google.com/protocol-buffers) Messages with a simple DSL similar to [JBuilder](https://rubygems.org/gems/jbuilder) gem. ## Usage -How to use my plugin. +It basically works exactly like jbuilder. The main difference is that it can use introspection to figure out what kind of protobuf message it needs to create. + + +Following Pbbuilder code +``` +person = RPC::Person.new + Pbbuilder.new(person) do |pb| + pb.name "Hello" + pb.friends [1, 2, 3] do |number| + pb.name "Friend ##{number}" + end + end +``` +Would produce this message: + +``` +message Person { + string name = 1; + repeated Person friends = 2; +} +``` + + +### Caching +Fragment caching is supported, it uses Rails.cache and works like caching in HTML templates: + +``` +pb.cache! "cache-key", expires_in: 10.minutes do + pb.name @person.name +end +``` + +You can also conditionally cache a block by using cache_if! like this: + +``` +pb.cache_if! !admin?, "cache-key", expires_in: 10.minutes do + pb.name @person.name +end +``` + ## Installation Add this line to your application's Gemfile: ```ruby