Module: MassiveRecord::ORM::Config::ClassMethods

Extended by:
ActiveSupport::Memoizable
Defined in:
lib/massive_record/orm/config.rb

Constant Summary collapse

@@connection =
nil

Instance Method Summary collapse

Instance Method Details

#connectionObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/massive_record/orm/config.rb', line 15

def connection
  if @@connection.blank?
    @@connection = if !connection_configuration.empty?
                    MassiveRecord::Wrapper::Connection.new(connection_configuration)
                  elsif defined? ::Rails
                    MassiveRecord::Wrapper::Base.connection
                  else
                    raise ConnectionConfigurationMissing
                  end

    @@connection.open
  end
  @@connection
end

#reset_connection!Object



30
31
32
# File 'lib/massive_record/orm/config.rb', line 30

def reset_connection!
  @@connection = nil
end

#tableObject



35
36
37
# File 'lib/massive_record/orm/config.rb', line 35

def table
  MassiveRecord::Wrapper::Table.new(connection, table_name)
end

#table_exists?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/massive_record/orm/config.rb', line 41

def table_exists?
  connection.tables.include?(table_name)
end