Module: Mack::Database

Defined in:
lib/mack-orm/database.rb,
lib/mack-orm/paginator.rb,
lib/mack-orm/generators.rb,
lib/mack-orm/database_migrations.rb

Defined Under Namespace

Modules: Generators, Migrations Classes: Paginator

Class Method Summary collapse

Class Method Details

.clear_connection(env = Mack.env) ⇒ Object

Clears connections to the database

Raises:

  • (NoMethodError)


11
12
13
# File 'lib/mack-orm/database.rb', line 11

def self.clear_connection(env = Mack.env)
  raise NoMethodError.new(:clear_connection)
end

.create(env = Mack.env, repis = :default) ⇒ Object

Creates a database, if it doesn’t already exist for the specified environment

Raises:

  • (NoMethodError)


16
17
18
# File 'lib/mack-orm/database.rb', line 16

def self.create(env = Mack.env, repis = :default)
  raise NoMethodError.new(:create)
end

.drop(env = Mack.env, repis = :default) ⇒ Object

Drops a database, if it exists for the specified environment

Raises:

  • (NoMethodError)


21
22
23
# File 'lib/mack-orm/database.rb', line 21

def self.drop(env = Mack.env, repis = :default)
  raise NoMethodError.new(:drop)
end

.dump_structure(env = Mack.env, repis = :default) ⇒ Object

Dumps the structure of the database to a file.

Raises:

  • (NoMethodError)


37
38
39
# File 'lib/mack-orm/database.rb', line 37

def self.dump_structure(env = Mack.env, repis = :default)
  raise NoMethodError.new(:dump_structure)
end

.establish_connection(env = Mack.env) ⇒ Object

Sets up and establishes connections to the database based on the specified environment and the settings in the database.yml file.

Raises:

  • (NoMethodError)


6
7
8
# File 'lib/mack-orm/database.rb', line 6

def self.establish_connection(env = Mack.env)
  raise NoMethodError.new(:establish_connection)
end

.load_structure(file, env = Mack.env, repis = :default) ⇒ Object

Loads the structure of the given file into the database

Raises:

  • (NoMethodError)


32
33
34
# File 'lib/mack-orm/database.rb', line 32

def self.load_structure(file, env = Mack.env, repis = :default)
  raise NoMethodError.new(:load_structure)
end

.paginate(klass, options = {}, query_options = {}) ⇒ Object

Creates a new Mack::Database::Paginator class and calls the paginate method on it.



5
6
7
8
# File 'lib/mack-orm/paginator.rb', line 5

def self.paginate(klass, options = {}, query_options = {})
  paginator = Mack::Database::Paginator.new(klass, options, query_options)
  paginator.paginate
end

.recreate(env = Mack.env, repis = :default) ⇒ Object

Drops and then creates the database.



26
27
28
29
# File 'lib/mack-orm/database.rb', line 26

def self.recreate(env = Mack.env, repis = :default)
  Mack::Database.drop(env, repis)
  Mack::Database.create(env, repis)
end