Class: PgTrigger::Plan::Builder
- Inherits:
-
Object
- Object
- PgTrigger::Plan::Builder
- Defined in:
- lib/pg_trigger/plan.rb
Instance Method Summary collapse
-
#initialize(expected, existing) ⇒ Builder
constructor
A new instance of Builder.
- #result ⇒ Object
Constructor Details
#initialize(expected, existing) ⇒ Builder
Returns a new instance of Builder.
11 12 13 14 |
# File 'lib/pg_trigger/plan.rb', line 11 def initialize(expected, existing) @expected = expected @existing = existing end |
Instance Method Details
#result ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pg_trigger/plan.rb', line 16 def result plan = Plan.new # Find new or updated triggers @expected.each do |t| e = @existing.find { |_t| _t.name == t.name } if e plan.update_trigger(e, t) unless t.same?(e) else plan.add_trigger(t) end end # Find removed triggers @existing.each do |e| next if @expected.any? { |t| t.name == e.name } plan.drop_trigger(e) end plan end |