Class: Dsu::Models::MigrationVersion
- Inherits:
-
Crud::JsonFile
- Object
- Crud::JsonFile
- Dsu::Models::MigrationVersion
- Includes:
- Support::Fileable
- Defined in:
- lib/dsu/models/migration_version.rb
Overview
This class represents a dsu migration_version.
Constant Summary
Constants included from Support::Fileable
Support::Fileable::MIGRATION_VERSION_FILE_NAME
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Attributes inherited from Crud::JsonFile
Instance Method Summary collapse
-
#current_migration? ⇒ Boolean
Returns true if the current dsu install is the current migration version.
-
#initialize(version: nil, options: {}) ⇒ MigrationVersion
constructor
A new instance of MigrationVersion.
- #to_h ⇒ Object
Methods included from Support::Fileable
#backup_folder, #config_file_name, #config_folder, #config_path, #dsu_folder, #entries_file_name, #entries_folder, #entries_path, #gem_dir, #migration_version_folder, #migration_version_path, #root_folder, #seed_data_folder, #temp_folder, #theme_file_name, #themes_folder, #themes_path
Methods inherited from Crud::JsonFile
#delete, delete, #delete!, delete!, file_does_not_exist_message, file_exist?, #file_exist?, parse, #persisted?, read, read!, #reload, #save, #save!, #to_model, #write, write, #write!, write!
Constructor Details
#initialize(version: nil, options: {}) ⇒ MigrationVersion
Returns a new instance of MigrationVersion.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/dsu/models/migration_version.rb', line 18 def initialize(version: nil, options: {}) super(migration_version_path) FileUtils.mkdir_p migration_version_folder @options = || {} @version = version and return if version file_hash = if exist? read do |migration_version_hash| hydrated_hash = Services::MigrationVersion::HydratorService.new(migration_version_hash: migration_version_hash).call migration_version_hash.merge!(hydrated_hash) end end self.version = file_hash.try(:[], :version) || 0 end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
14 15 16 |
# File 'lib/dsu/models/migration_version.rb', line 14 def @options end |
Instance Method Details
#current_migration? ⇒ Boolean
Returns true if the current dsu install is the current migration version.
39 40 41 |
# File 'lib/dsu/models/migration_version.rb', line 39 def current_migration? version == Dsu::Migration::VERSION end |
#to_h ⇒ Object
43 44 45 46 47 |
# File 'lib/dsu/models/migration_version.rb', line 43 def to_h { version: version } end |