Class: DbDumper::QueryBuilder::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/db_dumper/query_builder/table.rb

Overview

Storage for generated classes inherited from ActiveRecord::Base

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#table_nameObject (readonly)

Returns the value of attribute table_name.



9
10
11
# File 'lib/db_dumper/query_builder/table.rb', line 9

def table_name
  @table_name
end

Class Method Details

.from(raw_table) ⇒ Object



13
14
15
16
17
18
# File 'lib/db_dumper/query_builder/table.rb', line 13

def self.from(raw_table)
  return raw_table if raw_table.is_a?(Table)

  table_name_str = raw_table.to_s
  @tables[table_name_str] ||= new(table_name_str)
end

Instance Method Details

#arObject



20
21
22
23
24
# File 'lib/db_dumper/query_builder/table.rb', line 20

def ar
  @ar ||= Class.new(ActiveRecord::Base).tap do |klass|
    klass.table_name = table_name
  end
end