Methods

Class/Module Index [+]

Quicksearch

Sequel::Plugins::JsonSerializer::DatasetMethods

Public Instance Methods

to_json(*a) click to toggle source

Return a JSON string representing an array of all objects in this dataset. Takes the same options as the the instance method, and passes them to every instance.

# File lib/sequel/plugins/json_serializer.rb, line 199
def to_json(*a)
  if opts = a.first.is_a?(Hash)
    opts = model.json_serializer_opts.merge(a.first)
    a = []
  else
    opts = model.json_serializer_opts
  end
  res = row_proc ? all.map{|obj| Literal.new(obj.to_json(opts))} : all
  opts[:root] ? {model.send(:pluralize, model.send(:underscore, model.to_s)) => res}.to_json(*a) : res.to_json(*a)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.