Class: Sqrbl::Conversion
- Includes:
- HasTodos
- Defined in:
- lib/sqrbl/conversion.rb
Overview
The Conversion class doesn’t do much on its own; it’s basically just a container for a list of Group objects, which are created using #group.
Note also that because Group includes the MethodMissingDelegation mixin, instance methods defined in the block given to Conversion.build will become available to all groups (and their related objects) that belong to a Conversion instance. For more information, see MethodMissingDelegation.
Instance Attribute Summary collapse
-
#creating_file ⇒ Object
readonly
Returns the value of attribute creating_file.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#output_directory ⇒ Object
readonly
Returns the value of attribute output_directory.
Class Method Summary collapse
-
.build(&block) ⇒ Object
Creates a new Conversion object and evaluates the block in its binding.
Instance Method Summary collapse
-
#down_steps ⇒ Object
Convenience method: iterate all ‘down’ steps in the conversion.
-
#group(name, &block) ⇒ Object
Creates a Group object, passing it the name and block arguments.
-
#initialize ⇒ Conversion
constructor
:nodoc:.
-
#set_output_directory(dirname) ⇒ Object
Convenience method: set the
output_directory
attribute. -
#step_pairs ⇒ Object
Convenience method: iterate all StepPair objects in the conversion.
-
#up_steps ⇒ Object
Convenience method: iterate all ‘up’ steps in the conversion.
Methods included from HasTodos
Constructor Details
#initialize ⇒ Conversion
:nodoc:
31 32 33 34 35 |
# File 'lib/sqrbl/conversion.rb', line 31 def initialize # :nodoc: @groups = [] creating_caller = CallStack.first_non_sqrbl_caller @creating_file = File.(CallStack.caller_file(creating_caller)) end |
Instance Attribute Details
#creating_file ⇒ Object (readonly)
Returns the value of attribute creating_file.
15 16 17 |
# File 'lib/sqrbl/conversion.rb', line 15 def creating_file @creating_file end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
15 16 17 |
# File 'lib/sqrbl/conversion.rb', line 15 def groups @groups end |
#output_directory ⇒ Object (readonly)
Returns the value of attribute output_directory.
15 16 17 |
# File 'lib/sqrbl/conversion.rb', line 15 def output_directory @output_directory end |
Class Method Details
.build(&block) ⇒ Object
Creates a new Conversion object and evaluates the block in its binding. As a result, any methods called within the block will affect the state of that object (and that object only).
(Eventually, this will also pass the conversion to a helper object that will create the tree of output *.sql files.)
25 26 27 28 29 |
# File 'lib/sqrbl/conversion.rb', line 25 def self.build(&block) returning(self.new) do |conversion| conversion.instance_eval(&block) end end |
Instance Method Details
#down_steps ⇒ Object
Convenience method: iterate all ‘down’ steps in the conversion
58 59 60 |
# File 'lib/sqrbl/conversion.rb', line 58 def down_steps step_pairs.map(&:down_step) end |
#group(name, &block) ⇒ Object
Creates a Group object, passing it the name and block arguments.
43 44 45 |
# File 'lib/sqrbl/conversion.rb', line 43 def group(name, &block) groups << Group.new(self, name, &block) end |
#set_output_directory(dirname) ⇒ Object
Convenience method: set the output_directory
attribute
38 39 40 |
# File 'lib/sqrbl/conversion.rb', line 38 def set_output_directory(dirname) self.output_directory = File.(dirname) end |
#step_pairs ⇒ Object
Convenience method: iterate all StepPair objects in the conversion
48 49 50 |
# File 'lib/sqrbl/conversion.rb', line 48 def step_pairs groups.map(&:steps).flatten end |
#up_steps ⇒ Object
Convenience method: iterate all ‘up’ steps in the conversion
53 54 55 |
# File 'lib/sqrbl/conversion.rb', line 53 def up_steps step_pairs.map(&:up_step) end |