Class: Sqrbl::StepPair
- Includes:
- ExpectsBlockWithNew, HasTodos, MethodMissingDelegation
- Defined in:
- lib/sqrbl/step_pair.rb
Overview
Like the Group class, StepPair doesn’t do much on its own. It’s basically a container for two Step objects, which are created using up
and down
. These two steps will usually, but not always, have a one-to-one correspondence in their actions. (For example, a temp table may take a number of actions to create and populate, but removing it just takes a “DROP TABLE” statement.)
-
The
up_step
describes the actions necessary to move the source data one step closer to the target format. -
The
down_step
describes the actions necessary to undo the actions taken by the up_step.
StepPair delegates method_missing
calls to its group
object. For more information, see MethodMissingDelegation.
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#down_step ⇒ Object
readonly
Returns the value of attribute down_step.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#up_step ⇒ Object
readonly
Returns the value of attribute up_step.
Instance Method Summary collapse
-
#down(&block) ⇒ Object
Create a Step object, passing it the block.
-
#initialize(group, description, options = {}, &block) ⇒ StepPair
constructor
A new instance of StepPair.
- #unix_name ⇒ Object
-
#up(&block) ⇒ Object
Create a Step object, passing it the block.
-
#valid? ⇒ Boolean
A StepPair is valid if both the up_step and the down_step have been created as Step objects.
Methods included from HasTodos
Methods included from MethodMissingDelegation
Constructor Details
#initialize(group, description, options = {}, &block) ⇒ StepPair
Returns a new instance of StepPair.
29 30 31 32 33 34 35 |
# File 'lib/sqrbl/step_pair.rb', line 29 def initialize(group, description, = {}, &block) @group = group @description = description @block = lambda(&block) eval_block_on_initialize() end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
21 22 23 |
# File 'lib/sqrbl/step_pair.rb', line 21 def block @block end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
21 22 23 |
# File 'lib/sqrbl/step_pair.rb', line 21 def description @description end |
#down_step ⇒ Object (readonly)
Returns the value of attribute down_step.
22 23 24 |
# File 'lib/sqrbl/step_pair.rb', line 22 def down_step @down_step end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
21 22 23 |
# File 'lib/sqrbl/step_pair.rb', line 21 def group @group end |
#up_step ⇒ Object (readonly)
Returns the value of attribute up_step.
22 23 24 |
# File 'lib/sqrbl/step_pair.rb', line 22 def up_step @up_step end |
Instance Method Details
#down(&block) ⇒ Object
Create a Step object, passing it the block.
43 44 45 |
# File 'lib/sqrbl/step_pair.rb', line 43 def down(&block) @down_step = Step.new(self, &block) end |
#unix_name ⇒ Object
52 53 54 |
# File 'lib/sqrbl/step_pair.rb', line 52 def unix_name Sqrbl.calculate_unix_name(description) end |
#up(&block) ⇒ Object
Create a Step object, passing it the block.
38 39 40 |
# File 'lib/sqrbl/step_pair.rb', line 38 def up(&block) @up_step = Step.new(self, &block) end |
#valid? ⇒ Boolean
A StepPair is valid if both the up_step and the down_step have been created as Step objects.
48 49 50 |
# File 'lib/sqrbl/step_pair.rb', line 48 def valid? [up_step, down_step].all? { |step| step.kind_of?(Step) } end |