Class: Convergence::DSL
- Inherits:
-
Object
- Object
- Convergence::DSL
- Defined in:
- lib/convergence/dsl.rb
Instance Attribute Summary collapse
-
#current_dir_path ⇒ Object
Returns the value of attribute current_dir_path.
-
#tables ⇒ Object
Returns the value of attribute tables.
Class Method Summary collapse
Instance Method Summary collapse
- #create_table(table_name, options = {}, &block) ⇒ Object
- #include(path) ⇒ Object
-
#initialize ⇒ DSL
constructor
A new instance of DSL.
Constructor Details
#initialize ⇒ DSL
Returns a new instance of DSL.
6 7 8 |
# File 'lib/convergence/dsl.rb', line 6 def initialize @tables = {} end |
Instance Attribute Details
#current_dir_path ⇒ Object
Returns the value of attribute current_dir_path.
4 5 6 |
# File 'lib/convergence/dsl.rb', line 4 def current_dir_path @current_dir_path end |
#tables ⇒ Object
Returns the value of attribute tables.
4 5 6 |
# File 'lib/convergence/dsl.rb', line 4 def tables @tables end |
Class Method Details
.parse(code, current_dir_path) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/convergence/dsl.rb', line 22 def self.parse(code, current_dir_path) parser = new parser.current_dir_path = current_dir_path parser.instance_eval(code) parser.tables end |
Instance Method Details
#create_table(table_name, options = {}, &block) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/convergence/dsl.rb', line 10 def create_table(table_name, = {}, &block) table = Convergence::Table.new(table_name.to_s, ) block.call(table) @tables[table_name.to_s] = table table end |
#include(path) ⇒ Object
17 18 19 20 |
# File 'lib/convergence/dsl.rb', line 17 def include(path) next_dir_path = File.dirname("#{@current_dir_path}/#{path}") @tables.merge!(Convergence::DSL.parse(File.open("#{current_dir_path}/#{path}").read, next_dir_path)) end |