# frozen_string_literal: true class BasicSerializer module DSL def attributes @attributes ||= {} end def attribute(name, type = nil) attributes[name] = type || :default return if @defined_methods&.include?(name) @defined_methods ||= Set.new @defined_methods << name define_method(name) { object.public_send(name) } end def model_name(name) @model_name = name end def custom_model_name @custom_model_name ||= @model_name || name.delete_suffix("Serializer") end def schema_ref(ref) @schema_ref = ref end def format(name, pretty: false) @format = { name: name, pretty: pretty } end def format_settings @format_settings ||= {} end end end