Module: ActiveHashExt::ClassMethods

Defined in:
lib/active_hash_ext.rb

Instance Method Summary collapse

Instance Method Details

#destroy_allObject



27
28
29
# File 'lib/active_hash_ext.rb', line 27

def destroy_all
  delete_all
end

#read_schema(table, path) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/active_hash_ext.rb', line 10

def read_schema(table, path)
  tables = File.read(path).split(/^\s*create_/)[1..-1].map {|table_data| Table.parse table_data }
  table = tables.select do |_table|
    _table.name == table
  end
  unless table.first.nil?
    table.first.attributes.map do |attribute|
      attribute.name.to_sym
    end
  end

  if table.first.nil?
    raise "Table Name not Found!"
  end

end