Module: Common::ClassMethods

Overview

require 'app/models/IncludeModuleClassMethods.rb'

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 ColumnGroup::ClassMethods

#attribute_ddl, #attribute_rails_type, #attribute_ruby_type, #candidate_logical_keys_from_indexes, #categorical?, #column_symbols, #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

#activeRecordTableNotCreatedYet?(obj) ⇒ Boolean

Returns:

  • (Boolean)

63
64
65
# File 'app/models/no_db.rb', line 63

def activeRecordTableNotCreatedYet?(obj)
	return (obj.class.inspect=~/^[a-zA-Z0-9_]+\(Table doesn\'t exist\)/)==0
end

#class_of_name(name) ⇒ Object


33
34
35
36
37
# File 'app/models/no_db.rb', line 33

def class_of_name(name)
	 return name.to_s.constantize
rescue
	return nil
end

#is_generic_table?(model_class_name) ⇒ Boolean

class_of_name

Returns:

  • (Boolean)

38
39
40
41
42
43
44
45
46
# File 'app/models/no_db.rb', line 38

def is_generic_table?(model_class_name)
	return false if (model_class_name =~ /_ids$/)
	if is_ActiveRecord_table?(model_class_name) then
		model_class=eval_constant(model_class_name.classify)
		model_class.module_included?(Generic_Table)
	else
		return false
	end #if
end

#is_generic_table_name?(model_file_basename, directory = 'app/models/', extention = '.rb') ⇒ Boolean

rails_MVC_class

Returns:

  • (Boolean)

53
54
55
56
57
58
59
60
# File 'app/models/no_db.rb', line 53

def is_generic_table_name?(model_file_basename,directory='app/models/',extention='.rb')
	if File.exists?(directory+model_file_basename+extention) then
		return true
	else
#		puts "File.exists?(\"#{directory+model_file_basename+extention})\")=#{File.exists?(directory+model_file_basename+extention)}"
		return false
	end #if
end

#rails_MVC_class?(table_name) ⇒ Boolean

table_exists

Returns:

  • (Boolean)

50
51
52
# File 'app/models/no_db.rb', line 50

def rails_MVC_class?(table_name)
	return CodeBase.rails_MVC_classes.map{|c| c.name}.include?(table_name.to_s.classify)
end

#table_exists?(table_name) ⇒ Boolean

def

Returns:

  • (Boolean)

47
48
49
# File 'app/models/no_db.rb', line 47

def table_exists?(table_name)
	TableSpec.connection.table_exists?(table_name)
end