Class: Cassie::Schema::VersionLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/cassie/schema/version_loader.rb

Direct Known Subclasses

VersionFileLoader, VersionObjectLoader

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



5
6
7
# File 'lib/cassie/schema/version_loader.rb', line 5

def filename
  @filename
end

#versionObject (readonly)

Returns the value of attribute version.



5
6
7
# File 'lib/cassie/schema/version_loader.rb', line 5

def version
  @version
end

Instance Method Details

#loadVersion, Boolean

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

Returns:

  • (Version, Boolean)

    The Version object if successful. In other words, if object representing the version returns a Cassie::Schema::Migration object. Otherwise returns false.

Raises:

  • (NameError)

    if the migration class could not be loaded



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 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