Method: Porridge::SerializerDefiner#method_missing

Defined in:
lib/porridge/serializer_definer.rb

#method_missing(method_name, *args, **kwargs, &block) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/porridge/serializer_definer.rb', line 21

def method_missing(method_name, *args, **kwargs, &block)
  method_name = method_name.to_s
  if create_method? method_name
    return factory.send(method_name.delete_prefix(FACTORY_PREFIX), *args, **kwargs, &block)
  end

  to_send = SERIALIZER_SUFFIX if serializer_method? method_name
  to_send = FIELD_SERIALIZER_SUFFIX if field_serializer_method? method_name

  return add_serializer(factory.send(method_name + to_send, *args, **kwargs, &block)) if to_send

  super(method_name.to_sym, *args, &block)
end