Module: NoDB::ClassMethods

Overview

include ActiveModel # trying to fulfill Rails 3 promise that ActiveModel would allow non-ActiveRecord classes to share methods. include Generic_Table extend Generic_Table::ClassMethods

Constant Summary

Constants included from ColumnGroup::ClassMethods

ColumnGroup::ClassMethods::History_columns

Constants included from GenericGrep::ClassMethods

GenericGrep::ClassMethods::ASSOCIATION_MACRO_LETTERS, GenericGrep::ClassMethods::ASSOCIATION_MACRO_PATTERN

Instance Method Summary collapse

Methods included from Generic_Table::ClassMethods

#is_active_record_method?, #model_file_name, #nesting, #one_pass_statistics, #sample, #sample_burst

Methods included from ColumnGroup::ClassMethods

#attribute_ddl, #attribute_rails_type, #attribute_ruby_type, #candidate_logical_keys_from_indexes, #categorical?, #default_logical_primary_key, #defaulted_primary_logical_key?, #history_type?, #is_logical_primary_key?, #logical_attributes, #logical_primary_key, #logical_primary_key_recursive, #numerical?, #probably_categorical?, #probably_numerical?, #sequential_id?

Methods included from GenericGrep::ClassMethods

#all_associations, #association_grep, #association_grep_pattern, #association_macro_type, #association_type, #belongs_to_association?, #grep_all_associations_command, #grep_command, #has_many_association?, #has_one_association?, #model_grep, #model_grep_command

Methods included from GenericTableHtml::ClassMethods

#column_order, #header_html, #table_html

Instance Method Details

#column_symbolsObject

include Generic_Table::ClassMethods


418
419
420
421
422
# File 'app/models/no_db.rb', line 418

def column_symbols
	column_names=sample.flatten.map do |r|
		r.keys.map {|name| name.downcase.to_sym}
	end.flatten.uniq #map
end

#data_source_yaml(yaml_table_name = table_name) ⇒ Object

dump


447
448
449
# File 'app/models/no_db.rb', line 447

def data_source_yaml(yaml_table_name=table_name)
	yaml = YAML::load( File.open("test/data_sources/#{yaml_table_name}.yml" ) )
end

#default_names(values_or_size, prefix = 'Col_') ⇒ Object

NoDB.table_name


429
430
431
432
433
434
435
436
437
438
# File 'app/models/no_db.rb', line 429

def default_names(values_or_size, prefix='Col_')
	if values_or_size.instance_of?(Array) then
		size=values_or_size.size
	elsif values_or_size.instance_of?(Fixnum) then
		size=values_or_size
	else
		raise "values_or_size=#{values_or_size.inspect} is a #{values_or_size.class} not an Array or Fixnum."
	end #if
	Array.new(size) {|i| prefix+i.to_s}
end

#dumpObject

insert_sql


442
443
444
445
446
# File 'app/models/no_db.rb', line 442

def dump
	all.map do |record|
		record.insert_sql
	end #map
end

#get_field_namesObject

data_source_yaml


450
451
452
# File 'app/models/no_db.rb', line 450

def get_field_names
	feild_names=all.first.keys
end

#insert_sql(record) ⇒ Object

default_names


439
440
441
# File 'app/models/no_db.rb', line 439

def insert_sql(record)
	record.insert_sql
end

#table_classObject

column_symbols


423
424
425
# File 'app/models/no_db.rb', line 423

def table_class
	return self
end

#table_nameObject

NoDB.table_class


426
427
428
# File 'app/models/no_db.rb', line 426

def table_name
	return table_class.name.tableize
end