Class: PgPartitions::SQL::If
- Inherits:
-
Struct
- Object
- Struct
- PgPartitions::SQL::If
- Defined in:
- lib/pg_partitions/sql.rb
Instance Attribute Summary collapse
-
#conditions ⇒ Object
Returns the value of attribute conditions.
Instance Method Summary collapse
Instance Attribute Details
#conditions ⇒ Object
Returns the value of attribute conditions
9 10 11 |
# File 'lib/pg_partitions/sql.rb', line 9 def conditions @conditions end |
Instance Method Details
#to_sql ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pg_partitions/sql.rb', line 10 def to_sql if conditions.empty? raise ArgumentError, 'You must provide at least one condition' end lines = conditions.map do |opts| if opts.key? :if build_condition :if, opts elsif opts.key? :elsif build_condition :elsif, opts else opts.key? :else "ELSE\n #{opts[:else]}" end end lines << 'END IF;' lines.join("\n") << "\n" end |