Class: PgMeta::Trigger

Inherits:
Node
  • Object
show all
Defined in:
lib/pg_meta/meta.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#name, #parent, #root

Instance Method Summary collapse

Methods inherited from Node

#dump, #dump_value, #guid, #inspect, #sid, #to_s, #to_yaml, #uid

Constructor Details

#initialize(table, name, function, level, timing, events) ⇒ Trigger

Note that trigger names have a ‘()’ suffixed. This avoid namespace collisions with field names



577
578
579
580
581
582
583
584
585
# File 'lib/pg_meta/meta.rb', line 577

def initialize(table, name, function, level, timing, events)
  super(table, name)
  @name = "#{name}()"
  @function = function
  @level = level.to_sym
  @timing = timing.to_sym
  @events = events
  table.triggers[@name] = self
end

Instance Attribute Details

#eventsObject (readonly)

Array of events (:insert, :update, :delete, or :truncate) causing the trigger to fire



573
574
575
# File 'lib/pg_meta/meta.rb', line 573

def events
  @events
end

#functionObject (readonly)

Trigger function



564
565
566
# File 'lib/pg_meta/meta.rb', line 564

def function
  @function
end

#levelObject (readonly)

Trigger level (:stmt or :row)



567
568
569
# File 'lib/pg_meta/meta.rb', line 567

def level
  @level
end

#timingObject (readonly)

When trigger is fired (:before, :after, or :instead)



570
571
572
# File 'lib/pg_meta/meta.rb', line 570

def timing
  @timing
end

Instance Method Details

#to_hObject



587
# File 'lib/pg_meta/meta.rb', line 587

def to_h() attrs_to_h(:name, :function, :level, :timing, :events) end