Module: DataMapper::WAZTables::Migrations
- Defined in:
- lib/dm-waztables-adapter/migrations.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_model_storage(model) ⇒ Object
- #destroy_model_storage(model) ⇒ Object
- #storage_exists?(storage_name) ⇒ Boolean
- #upgrade_model_storage(model) ⇒ Object
Class Method Details
.included(base) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/dm-waztables-adapter/migrations.rb', line 4 def self.included(base) DataMapper.extend(DataMapper::Migrations::SingletonMethods) [ :Repository, :Model ].each do |name| DataMapper.const_get(name).send(:include, DataMapper::Migrations.const_get(name)) end end |
Instance Method Details
#create_model_storage(model) ⇒ Object
15 16 17 |
# File 'lib/dm-waztables-adapter/migrations.rb', line 15 def create_model_storage(model) WAZ::Tables::Table.create(model.storage_name) end |
#destroy_model_storage(model) ⇒ Object
23 24 25 26 |
# File 'lib/dm-waztables-adapter/migrations.rb', line 23 def destroy_model_storage(model) return unless (model_storage = self.storage_exists?(model.storage_name)) model_storage.destroy! end |
#storage_exists?(storage_name) ⇒ Boolean
11 12 13 |
# File 'lib/dm-waztables-adapter/migrations.rb', line 11 def storage_exists?(storage_name) WAZ::Tables::Table.find(storage_name) end |
#upgrade_model_storage(model) ⇒ Object
19 20 21 |
# File 'lib/dm-waztables-adapter/migrations.rb', line 19 def upgrade_model_storage(model) WAZ::Tables::Table.create(model.storage_name) unless self.storage_exists?(model.storage_name) end |