Parent

Methods

Included Modules

Rabl::MultiBuilder

Public Class Methods

new(data, settings = {}, options = {}) click to toggle source

Constructs a new MultiBuilder given the data and options. The options will be re-used for all Rabl::Builders. Rabl::MultiBuilder.new([#<User ...>, #<User ...>, ...], { :format => 'json', :child_root => true })

# File lib/rabl/multi_builder.rb, line 8
def initialize(data, settings = {}, options = {})
  @data                 = data
  @settings             = settings
  @options              = options
  @builders             = []
  @engine_to_builder    = {}
  @cache_key_to_engine  = {}
end

Public Instance Methods

to_a() click to toggle source

Returns the result of all of the builders as an array

# File lib/rabl/multi_builder.rb, line 18
def to_a
  generate_builders

  if template_cache_configured? && Rabl.configuration.use_read_multi
    map_engines_to_builders
    read_cache_results
    replace_engines_with_cache_results
  end

  result = @builders.map(&:to_hash)
  result = result.map(&:presence).compact if Rabl.configuration.exclude_empty_values_in_collections
  result
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.