lib/rabl/builder.rb in rabl-0.8.6 vs lib/rabl/builder.rb in rabl-0.9.0.pre

- old
+ new

@@ -97,12 +97,14 @@ # child(@user) { attribute :full_name } # child(@user => :person) { ... } # child(@users => :people) { ... } def child(data, options={}, &block) return false unless data.present? && resolve_condition(options) - name, object = data_name(data), data_object(data) + name = is_name_value?(options[:root]) ? options[:root] : data_name(data) + object = data_object(data) include_root = is_collection?(object) && options.fetch(:object_root, @options[:child_root]) # child @users engine_options = @options.slice(:child_root).merge(:root => include_root) + engine_options.merge!(:object_root_name => options[:object_root]) if is_name_value?(options[:object_root]) object = { object => name } if data.respond_to?(:each_pair) && object # child :users => :people @_result[name] = self.object_to_hash(object, engine_options, &block) end # Glues data from a child node to the json_output