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

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

Overview

Serega additional/patched class methods

See Also:

Instance Method Summary collapse

Instance Method Details

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

Configures response root key

Parameters:

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

    Specifies common root when serializing one or multiple objects

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

    Specifies root when serializing one object

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

    Specifies root when serializing multiple objects

Returns:

  • (Hash)

    Configured root names



111
112
113
114
115
116
# File 'lib/serega/plugins/root/root.rb', line 111

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

  config.root = {one: one, many: many}
end