class Fixtory::DSL::Builder
Attributes
_inserted[RW]
_tables[RW]
Public Class Methods
new()
click to toggle source
# File lib/fixtory/dsl/builder.rb, line 7 def initialize @_tables = [] end
Public Instance Methods
_eval_from_fixtory_file(path)
click to toggle source
# File lib/fixtory/dsl/builder.rb, line 15 def _eval_from_fixtory_file(path) contents = ::File.read(path) instance_eval(contents, path, 1) _tables.each do |table| if table._block table.instance_eval(&table._block) table._block = nil end end end
_insert()
click to toggle source
# File lib/fixtory/dsl/builder.rb, line 26 def _insert _tables.each do |table| table._rows.each do |row| _connection.insert_fixture(row.instance_eval('@attributes'), table._table_name) row.instance_eval("@inserted = true") end end self._inserted = true end
_table(name, &block)
click to toggle source
# File lib/fixtory/dsl/builder.rb, line 11 def _table(name, &block) _tables << ::Fixtory::DSL::Table.new(name, self, &block) end
method_missing(method, *args, &block)
click to toggle source
Calls superclass method
# File lib/fixtory/dsl/builder.rb, line 37 def method_missing(method, *args, &block) if block && block.respond_to?(:call) _table(method, &block) else table = _tables.find do |table| table._name == method.to_s end table || super end end
Private Instance Methods
_connection()
click to toggle source
# File lib/fixtory/dsl/builder.rb, line 51 def _connection ::ActiveRecord::Base.connection end