Module: SchemaPlus::Functions::Middleware::Dumper::Tables

Defined in:
lib/schema_plus/functions/middleware.rb

Instance Method Summary collapse

Instance Method Details

#after(env) ⇒ Object

Dump



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/schema_plus/functions/middleware.rb', line 8

def after(env)
  env.connection.functions.each do |(function_name, params, _options)|
    full_params, definition, function_type = env.connection.function_definition(function_name, params)
    heredelim                              = "END_FUNCTION_#{function_name.upcase}"
    extra_options                          = ", function_type: :#{function_type}" if function_type.present?
    statement                              = <<~ENDFUNCTION
      create_function "#{function_name}", "#{full_params}", <<-'#{heredelim}', :force => true#{extra_options}
      #{definition}
        #{heredelim}
    ENDFUNCTION

    env.dump.final << statement
  end
end