Module: PgSaurus::SchemaDumper::FunctionMethods
- Included in:
- PgSaurus::SchemaDumper
- Defined in:
- lib/pg_saurus/schema_dumper/function_methods.rb
Overview
Support for dumping database functions.
Instance Method Summary collapse
-
#dump_functions(stream) ⇒ Object
Writes out a command to create each detected function.
-
#tables_with_functions(stream) ⇒ Object
:nodoc.
Instance Method Details
#dump_functions(stream) ⇒ Object
Writes out a command to create each detected function.
14 15 16 17 18 19 20 21 22 |
# File 'lib/pg_saurus/schema_dumper/function_methods.rb', line 14 def dump_functions(stream) @connection.functions.each do |function| statement = " create_function '#{function.name}', :#{function.returning}, <<-FUNCTION_DEFINITION.gsub(/^[\s]{4}/, '')" statement << "\n#{function.definition.split("\n").map{|line| " #{line}" }.join("\n")}" statement << "\n FUNCTION_DEFINITION\n\n" stream.puts statement end end |
#tables_with_functions(stream) ⇒ Object
:nodoc
5 6 7 8 9 10 11 |
# File 'lib/pg_saurus/schema_dumper/function_methods.rb', line 5 def tables_with_functions(stream) tables_without_functions(stream) dump_functions stream stream end |