JezK
Edit File: array%21-i.ri
U:RDoc::AnyMethod[iI"array!:EFI"Jbuilder#array!;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"oTurns the current element into an array and iterates over the passed collection, adding each iteration as ;TI"'an element of the resulting array.;To:RDoc::Markup::BlankLine o; ; [I" Example:;T@o:RDoc::Markup::Verbatim; [I"&json.array!(@people) do |person| ;TI" json.name person.name ;TI"/ json.age calculate_age(person.birthday) ;TI" end ;TI" ;TI"F[ { "name": David", "age": 32 }, { "name": Jamie", "age": 31 } ] ;T:@format0o; ; [I"bIf you are using Ruby 1.9+, you can use the call syntax instead of an explicit extract! call:;T@o;; [I"%json.(@people) { |person| ... } ;T; 0o; ; [I"nIt's generally only needed to use this method for top-level arrays. If you have named arrays, you can do:;T@o;; [I"&json.people(@people) do |person| ;TI" json.name person.name ;TI"/ json.age calculate_age(person.birthday) ;TI" end ;TI" ;TI"T{ "people": [ { "name": David", "age": 32 }, { "name": Jamie", "age": 31 } ] } ;T; 0o; ; [I"IIf you omit the block then you can set the top level array directly:;T@o;; [I"json.array! [1, 2, 3] ;TI" ;TI"[1,2,3];T; 0: @fileI"lib/jbuilder.rb;T:0@omit_headings_from_table_of_contents_below000[ I"#(collection = [], *attributes);T@4FI" Jbuilder;TcRDoc::NormalClass00