Module: Serega::SeregaPlugins::Root::ClassMethods

Defined in:
lib/serega/plugins/root/root.rb

Instance Method Summary collapse

Instance Method Details

#root(root = nil, one: nil, many: nil) ⇒ Hash

Configures response root key

Parameters:

  • root (String, Symbol) (defaults to: nil)

    Specifies common root when serializing one or multiple objects

  • root_one (String, Symbol)

    Specifies root when serializing one object

  • root_many (String, Symbol)

    Specifies root when serializing multiple objects

Returns:

  • (Hash)

    Configured root names



33
34
35
36
37
38
39
40
41
# File 'lib/serega/plugins/root/root.rb', line 33

def root(root = nil, one: nil, many: nil)
  one ||= root
  many ||= root

  one = one.to_sym if one
  many = many.to_sym if many

  config[:root] = {one: one, many: many}
end