Class: Kiba::Extend::Registry::RegisteredFile

Inherits:
Object
  • Object
show all
Defined in:
lib/kiba/extend/registry/registered_file.rb

Overview

Abstract base class defining interface for destination files, lookup files, and source files returned by FileRegistry

Since:

  • 2.2.0

Defined Under Namespace

Classes: NoFilePathError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key:, data:, for_job:) ⇒ RegisteredFile

Returns a new instance of RegisteredFile.

Parameters:

  • key (Symbol)

    the FileRegistry lookup key

  • data (Hash)

    the hash of data for the file from FileRegistry

  • for_job (Symbol)

    registry entry job key of the job for which this registered file is being prepared

Raises:

  • (FileNotRegisteredError)

Since:

  • 2.2.0



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/kiba/extend/registry/registered_file.rb', line 32

def initialize(key:, data:, for_job:)
  raise FileNotRegisteredError, key unless data
  raise NoFilePathError, key if data.errors.keys.any?(:missing_path)

  @key = key
  @data = data
  @for_job = for_job
  @path = data.path.to_s
  @dest_class = data.dest_class
  @dest_opt = data.dest_opt
  @dest_special_opts = data.dest_special_opts
  @src_opt = data.src_opt
  @supplied = data.supplied
  @lookup_on = data.lookup_on
  @desc = data.desc
end

Instance Attribute Details

#dataObject (readonly)

Since:

  • 2.2.0



23
24
25
# File 'lib/kiba/extend/registry/registered_file.rb', line 23

def data
  @data
end

#descObject (readonly)

Since:

  • 2.2.0



23
24
25
# File 'lib/kiba/extend/registry/registered_file.rb', line 23

def desc
  @desc
end

#dest_classObject (readonly)

Since:

  • 2.2.0



23
24
25
# File 'lib/kiba/extend/registry/registered_file.rb', line 23

def dest_class
  @dest_class
end

#dest_optObject (readonly)

Since:

  • 2.2.0



23
24
25
# File 'lib/kiba/extend/registry/registered_file.rb', line 23

def dest_opt
  @dest_opt
end

#dest_special_optsObject (readonly)

Since:

  • 2.2.0



23
24
25
# File 'lib/kiba/extend/registry/registered_file.rb', line 23

def dest_special_opts
  @dest_special_opts
end

#keySymbol (readonly)

Returns The file’s key in FileRegistry hash.

Returns:



23
24
25
# File 'lib/kiba/extend/registry/registered_file.rb', line 23

def key
  @key
end

#lookup_onObject (readonly)

Since:

  • 2.2.0



23
24
25
# File 'lib/kiba/extend/registry/registered_file.rb', line 23

def lookup_on
  @lookup_on
end

#pathObject (readonly)

Since:

  • 2.2.0



23
24
25
# File 'lib/kiba/extend/registry/registered_file.rb', line 23

def path
  @path
end

#src_optObject (readonly)

Since:

  • 2.2.0



23
24
25
# File 'lib/kiba/extend/registry/registered_file.rb', line 23

def src_opt
  @src_opt
end

#suppliedObject (readonly)

Since:

  • 2.2.0



23
24
25
# File 'lib/kiba/extend/registry/registered_file.rb', line 23

def supplied
  @supplied
end

Instance Method Details

#src_classObject

Since:

  • 2.2.0



49
50
51
# File 'lib/kiba/extend/registry/registered_file.rb', line 49

def src_class
  supplied ? data.src_class : dest_src
end