Sha256: 80edf906d09a1a3049c741329def97a94273ab15e4f2fb3528feab5bdd59d147
Contents?: true
Size: 894 Bytes
Versions: 3
Compression:
Stored size: 894 Bytes
Contents
module ActiveMocker class SchemaReader attr_reader :model_name, :schema_file, :file_reader, :table def initialize(options={}) @file_reader = options[:file_reader] ||= FileReader @schema_file = options[:schema_file] end def search(model_name) @model_name = model_name @table = search_schema_file @table.fields.unshift Field.new('id', :integer, {}) @table end private def table_name model_name end def not_found raise "#{table_name} table not found." if @schema_result.nil? end def search_schema_file ActiveMocker::ActiveRecord::Schema.search(table_name) @schema_result = eval_file not_found @schema_result end def eval_file m = Module.new m.module_eval(read_file) end def read_file file_reader.read(schema_file) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
active_mocker-1.1.9 | lib/active_mocker/schema_reader.rb |
active_mocker-1.1.8 | lib/active_mocker/schema_reader.rb |
active_mocker-1.1.7 | lib/active_mocker/schema_reader.rb |