class Cassie::Schema::VersionLoader

Attributes

filename[R]
version[R]

Public Instance Methods

load() click to toggle source

Requires the ruby file, thus loading the Migration class into the ObjectSpace.

@return [Version, Boolean] The Version object if successful. In other words, if

object representing the version returns a Cassie::Schema::Migration object.
Otherwise returns false.

@raise [NameError] if the migration class could not be loaded

# File lib/cassie/schema/version_loader.rb, line 14
def load
  return false unless filename
  require filename

  begin
    # ensure the migration class is now defined
    version.migration_class_name.constantize
    if version.migration.is_a?(Cassie::Schema::Migration)
      version
    else
      false
    end
  rescue NameError
    raise NameError.new("Expected #{version.migration_class_name} to be defined in #{filename}, but it was not.")
  end
end