Class: WipeOut::Plans::BuiltPlan

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/wipe_out/plans/built_plan.rb

Overview

Provides final API after the plan had been build

Under the hood it contains plans but hides our under the hood implemention where we have helper methods for adding relations, attributes, etc.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(plan) ⇒ BuiltPlan

Returns a new instance of BuiltPlan.



10
11
12
# File 'lib/wipe_out/plans/built_plan.rb', line 10

def initialize(plan)
  @plan = plan
end

Instance Attribute Details

#planObject (readonly)

Returns the value of attribute plan.



15
16
17
# File 'lib/wipe_out/plans/built_plan.rb', line 15

def plan
  @plan
end

Instance Method Details

#execute(record) ⇒ Object

Executes plan on a record



30
31
32
# File 'lib/wipe_out/plans/built_plan.rb', line 30

def execute(record)
  WipeOut::Execute.call(plan, record.class, record)
end

#validate(ar_class) ⇒ Array<String>

Validates and returns any errors if validation fails.

It's not done automatically when plan is defined because plans can be combined and not be valid standalone.

Returns:

  • (Array<String>)

    empty if everything is OK with the plan. Returns non-empty list if issues are detected. You should call it in tests to ensure that plans are OK.



25
26
27
# File 'lib/wipe_out/plans/built_plan.rb', line 25

def validate(ar_class)
  WipeOut::Validate.call(plan, ar_class, @plan.config)
end