Class: PgPartitions::SQL::Function
- Inherits:
-
Struct
- Object
- Struct
- PgPartitions::SQL::Function
- Defined in:
- lib/pg_partitions/sql.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#name ⇒ Object
Returns the value of attribute name.
-
#table ⇒ Object
Returns the value of attribute table.
Instance Method Summary collapse
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body
40 41 42 |
# File 'lib/pg_partitions/sql.rb', line 40 def body @body end |
#name ⇒ Object
Returns the value of attribute name
40 41 42 |
# File 'lib/pg_partitions/sql.rb', line 40 def name @name end |
#table ⇒ Object
Returns the value of attribute table
40 41 42 |
# File 'lib/pg_partitions/sql.rb', line 40 def table @table end |
Instance Method Details
#to_sql ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/pg_partitions/sql.rb', line 41 def to_sql <<~SQL CREATE OR REPLACE FUNCTION #{name}() RETURNS TRIGGER AS $$ DECLARE result #{table}%rowtype; BEGIN #{body.indent(2)} RETURN result; END; $$ LANGUAGE plpgsql; SQL end |