Class: PgTrigger::Scanner

Inherits:
Object
  • Object
show all
Defined in:
lib/pg_trigger/scanner.rb

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ Scanner

Returns a new instance of Scanner.



7
8
9
10
11
12
13
# File 'lib/pg_trigger/scanner.rb', line 7

def initialize(str)
  @str = str
  @functions = {}
  @definitions = []

  parse
end

Instance Method Details

#triggersObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/pg_trigger/scanner.rb', line 15

def triggers
  @definitions.filter_map do |defn|
    trigger = Trigger.from_definition(defn)
    next nil unless trigger
    next nil unless trigger.name.end_with?("_tr")

    if (fn = @functions[trigger.name])
      trigger.set_content_from_function(fn)
    end

    trigger
  end
end