Module: PlainSerializer::Configurable::ClassMethods

Defined in:
lib/plain_serializer/configurable.rb

Overview

Defines required methods for base class

Instance Method Summary collapse

Instance Method Details

#setup(*args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/plain_serializer/configurable.rb', line 12

def setup(*args)
  opts = Helpers.extract_options!(args)

  attributes = args.each_with_object([]) do |attribute, result|
    next result << attribute unless group?(attribute)

    group(attribute).each do |group_attribute|
      if group_attribute.is_a?(Hash)
        opts.merge!(group_attribute)
      else
        result << group_attribute
      end
    end
  end

  super(*attributes, **opts)
end