Class: WipeOut::Plans::BuiltPlan
- Inherits:
-
Object
- Object
- WipeOut::Plans::BuiltPlan
- 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
-
#plan ⇒ Object
readonly
Returns the value of attribute plan.
Instance Method Summary collapse
-
#execute(record) ⇒ Object
Executes plan on a record.
-
#initialize(plan) ⇒ BuiltPlan
constructor
A new instance of BuiltPlan.
-
#validate(ar_class) ⇒ Array<String>
Validates and returns any errors if validation fails.
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
#plan ⇒ Object (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.
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 |