Class: WipeOut::Plans::Plan
- Inherits:
-
Object
- Object
- WipeOut::Plans::Plan
- Defined in:
- lib/wipe_out/plans/plan.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#callbacks ⇒ Object
readonly
Returns the value of attribute callbacks.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#ignored ⇒ Object
readonly
Returns the value of attribute ignored.
-
#relations ⇒ Object
readonly
Returns the value of attribute relations.
Instance Method Summary collapse
- #add_attribute(name, strategy:) ⇒ Object
- #add_callback(callback) ⇒ Object
- #add_relation(name, plan) ⇒ Object
- #add_relation_union(name, plans, &block) ⇒ Object
- #establish_execution_plan(_record) ⇒ Object
- #ignore(name) ⇒ Object
- #include_plan(other) ⇒ Object
-
#initialize(config) ⇒ Plan
constructor
A new instance of Plan.
- #inspect ⇒ Object
- #on_execute(arg = nil, &block) ⇒ Object
-
#plans ⇒ Object
Duck typing for plans union.
Constructor Details
#initialize(config) ⇒ Plan
Returns a new instance of Plan.
4 5 6 7 8 9 10 11 |
# File 'lib/wipe_out/plans/plan.rb', line 4 def initialize(config) @attributes = {} @ignored = [] @callbacks = [] @relations = {} @on_execute = nil @config = config end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
13 14 15 |
# File 'lib/wipe_out/plans/plan.rb', line 13 def attributes @attributes end |
#callbacks ⇒ Object (readonly)
Returns the value of attribute callbacks.
13 14 15 |
# File 'lib/wipe_out/plans/plan.rb', line 13 def callbacks @callbacks end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
13 14 15 |
# File 'lib/wipe_out/plans/plan.rb', line 13 def config @config end |
#ignored ⇒ Object (readonly)
Returns the value of attribute ignored.
13 14 15 |
# File 'lib/wipe_out/plans/plan.rb', line 13 def ignored @ignored end |
#relations ⇒ Object (readonly)
Returns the value of attribute relations.
13 14 15 |
# File 'lib/wipe_out/plans/plan.rb', line 13 def relations @relations end |
Instance Method Details
#add_attribute(name, strategy:) ⇒ Object
15 16 17 |
# File 'lib/wipe_out/plans/plan.rb', line 15 def add_attribute(name, strategy:) @attributes[name.to_sym] = strategy end |
#add_callback(callback) ⇒ Object
54 55 56 |
# File 'lib/wipe_out/plans/plan.rb', line 54 def add_callback(callback) @callbacks << callback end |
#add_relation(name, plan) ⇒ Object
19 20 21 |
# File 'lib/wipe_out/plans/plan.rb', line 19 def add_relation(name, plan) @relations[name.to_sym] = plan end |
#add_relation_union(name, plans, &block) ⇒ Object
23 24 25 |
# File 'lib/wipe_out/plans/plan.rb', line 23 def add_relation_union(name, plans, &block) @relations[name.to_sym] = Union.new(plans, block) end |
#establish_execution_plan(_record) ⇒ Object
50 51 52 |
# File 'lib/wipe_out/plans/plan.rb', line 50 def establish_execution_plan(_record) self end |
#ignore(name) ⇒ Object
31 32 33 |
# File 'lib/wipe_out/plans/plan.rb', line 31 def ignore(name) @ignored << name.to_sym end |
#include_plan(other) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/wipe_out/plans/plan.rb', line 35 def include_plan(other) @attributes.merge! other.attributes @ignored += other.ignored @relations.merge! other.relations @on_execute = other.on_execute other.callbacks.each do |callback| @callbacks << callback end end |
#inspect ⇒ Object
58 59 60 |
# File 'lib/wipe_out/plans/plan.rb', line 58 def inspect "Plan(attributes=#{attributes.keys})" end |
#on_execute(arg = nil, &block) ⇒ Object
27 28 29 |
# File 'lib/wipe_out/plans/plan.rb', line 27 def on_execute(arg = nil, &block) @on_execute = arg || block || @on_execute end |
#plans ⇒ Object
Duck typing for plans union
46 47 48 |
# File 'lib/wipe_out/plans/plan.rb', line 46 def plans [self] end |