class ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaStatements::Tutuf::ClassTableReflection

Public Class Methods

all_db_klasses() click to toggle source

Returns all models' class objects that are ActiveRecord::Base descendants

# File lib/updateable_views_inheritance/postgresql_adapter.rb, line 251
def all_db_klasses
  return @@klasses if defined?(@@klasses)
  @@klasses = []
  # load model classes so that inheritance_column is set correctly where defined
  model_filenames.collect{|m| load "#{Rails.root}/app/models/#{m}";m.match(%r{([^/]+?)\.rb$})[1].camelize.constantize }.each do |klass|
    @@klasses << klass if  klass < ActiveRecord::Base
  end
  @@klasses.uniq
end
get_klass_for_table(table_name) click to toggle source

Returns the class object for table_name

# File lib/updateable_views_inheritance/postgresql_adapter.rb, line 262
def get_klass_for_table(table_name)
  klass_for_tables()[table_name.to_s]
end
klass_for_tables() click to toggle source

Returns hash with tables and thier corresponding class. {table_name1 => ClassName1, …}

# File lib/updateable_views_inheritance/postgresql_adapter.rb, line 268
def klass_for_tables
  return @@tables_klasses if defined?(@@tables_klasses)
  @@tables_klasses = {}
  all_db_klasses.each do |klass|
    @@tables_klasses[klass.table_name] = klass if klass.respond_to?(:table_name)
  end
  @@tables_klasses
end
model_filenames() click to toggle source

Returns filenames for models in the current Rails application

# File lib/updateable_views_inheritance/postgresql_adapter.rb, line 278
def model_filenames
  Dir.chdir("#{Rails.root}/app/models"){ Dir["**/*.rb"] }
end