class Polymorpheus::Trigger
Attributes
charset[RW]
collation_connection[RW]
created[RW]
db_collation[RW]
definer[RW]
event[RW]
name[RW]
sql_mode[RW]
statement[RW]
table[RW]
timing[RW]
Public Class Methods
new(arr)
click to toggle source
# File lib/polymorpheus/trigger.rb, line 7 def initialize(arr) raise ArgumentError unless arr.is_a?(Array) && arr.length == 11 [:name, :event, :table, :statement, :timing, :created, :sql_mode, :definer, :charset, :collation_connection, :db_collation]. each_with_index do |attr, ind| self.send("#{attr}=", arr[ind]) end end
Public Instance Methods
columns()
click to toggle source
# File lib/polymorpheus/trigger.rb, line 16 def columns /IF\((.*)\) \<\> 1/.match(self.statement) do |match| match[1].split(' + ').collect do |submatch| /NEW\.([^ ]*)/.match(submatch)[1] end end end
schema_statement()
click to toggle source
# File lib/polymorpheus/trigger.rb, line 24 def schema_statement # note that we don't need to worry about unique indices or foreign keys # because separate schema statements will be generated for them " add_polymorphic_triggers(:#{table}, #{columns.to_s})" end