Module: PTJ::Model

Defined in:
lib/ptj/model.rb

Defined Under Namespace

Modules: FixtureTable

Class Method Summary collapse

Class Method Details

.migrate_all!Object

Updates the model schema in the current database.

Returns:

  • Object Returns the return value from DataMapper.auto_upgrade!



46
47
48
49
50
51
52
# File 'lib/ptj/model.rb', line 46

def self.migrate_all!
  setup! unless setup?
  # use a non-destructive schema migration across the whole model
  ret=DataMapper.auto_upgrade!
  @migrated = true
  return ret
end

.migrated?Boolean

Returns True,False Indicates whether the current model has been migrated (via auto_upgrade).

Returns:

  • (Boolean)

    True,False Indicates whether the current model has been migrated (via auto_upgrade).



57
58
59
# File 'lib/ptj/model.rb', line 57

def self.migrated?
  @migrated == true
end

.setup!Object

Sets up the model using with the currently configured db_conn configuration.



28
29
30
31
32
33
# File 'lib/ptj/model.rb', line 28

def self.setup!
  DataMapper::Logger.new($stdout, :debug) if Env::CONFIG[Env::KEY_DEBUG]
  DataMapper.setup(:default, Env::CONFIG[Env::KEY_DB_CONN])
  DataMapper.finalize
  @setup = true
end

.setup?Boolean

Returns True,False Indicates whether the the model has been set up yet with the setup! method.

Returns:

  • (Boolean)

    True,False Indicates whether the the model has been set up yet with the setup! method.



38
39
40
# File 'lib/ptj/model.rb', line 38

def self.setup?
  @setup == true
end